Skip to content

docs: regenerate architecture diagrams on every mkdocs build (#89)#96

Merged
Faerkeren merged 1 commit into
mainfrom
fix/89-docs-architecture-diagrams
May 27, 2026
Merged

docs: regenerate architecture diagrams on every mkdocs build (#89)#96
Faerkeren merged 1 commit into
mainfrom
fix/89-docs-architecture-diagrams

Conversation

@Faerkeren
Copy link
Copy Markdown
Contributor

Fixes #89.

Issue validity

Valid. Verified locally: mkdocs build --strict failed with two warnings about missing architecture/classes.svg and architecture/packages.svg. The page docs/architecture.md claimed the diagrams were "regenerated from source on every docs build," but mkdocs.yml did not actually invoke tools/generate_diagrams.py. CI ran the generator as a separate step (.github/workflows/docs.yml), but local strict builds were broken.

Fix

  • tools/mkdocs_hooks.py — new MkDocs on_pre_build hook that runs tools/generate_diagrams.py before MkDocs validates inter-page links. If pyreverse or Graphviz dot is unavailable, it writes minimal placeholder SVGs so mkdocs build --strict still succeeds.
  • mkdocs.yml — register the hook via the hooks: setting. This makes the documentation now genuinely regenerate diagrams on every build, matching the page's claim.
  • docs/architecture.md — rewrite to describe the real workflow accurately (hook + generator script + Graphviz prerequisite + manual regeneration command).
  • .gitignore — ignore docs/architecture/ (generated SVGs) and site/ (mkdocs output).
  • tests/test_mkdocs_hooks.py — 7 new tests covering: toolchain-missing fallback, generator-failure fallback, successful generation path, placeholder writer preserving existing files, _has_prerequisites false branches for missing dot and missing pyreverse, and _run_generator subprocess-failure path.

Validation

  • pytest tests/ --cov=haclient --cov-report=term-missing --cov-fail-under=95326 passed, coverage 97.18%
  • ruff check src tests tools — clean
  • ruff format --check src tests tools — clean
  • mypy src — clean (Success: no issues found in 38 source files)
  • mkdocs build --strict — succeeds locally; hook runs the generator and produces real SVGs

Add an MkDocs on_pre_build hook (tools/mkdocs_hooks.py) wired into
mkdocs.yml so that the architecture diagrams are actually regenerated
on every documentation build, matching what docs/architecture.md
claims. The hook invokes tools/generate_diagrams.py and falls back to
small placeholder SVGs when pyreverse or Graphviz is unavailable, so
'mkdocs build --strict' no longer fails on missing image links in
environments without the diagram toolchain.

- Update docs/architecture.md to describe the real workflow.
- Ignore docs/architecture/ and site/ in .gitignore so generated
  artifacts are not committed.
- Add tests/test_mkdocs_hooks.py covering the success path, the
  toolchain-missing fallback, the generator-failure fallback, and
  the placeholder writer's no-overwrite behaviour.
@Faerkeren Faerkeren merged commit ec14feb into main May 27, 2026
12 checks passed
@Faerkeren Faerkeren deleted the fix/89-docs-architecture-diagrams branch May 27, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore architecture diagrams so strict docs builds pass

1 participant