Documentation System Architecture¶
This project uses a Hybrid Documentation Model that combines the best of both worlds:
- MkDocs: For narrative documentation, guides, and tutorials.
- Doxygen: For auto-generated API reference, dependency graphs, and call hierarchies.
🏗️ Architecture¶
The build system (make docs) generates both sites and merges them into a single static site/ directory.
| Component | Tool | Config File | Output Path |
|---|---|---|---|
| Guides & UI | MkDocs | mkdocs.yml |
site/ |
| API Reference | Doxygen | Doxyfile |
site/doxygen/ |
Integration¶
- MkDocs creates the main website structure and navigation.
- Doxygen runs as a subprocess and outputs its HTML to a subdirectory.
- A Custom Layout (
docs/DoxygenLayout.xml) adds a "Back to Docs" link in the Doxygen sidebar to ensure seamless navigation between the two.
🛠️ Tools & Libraries¶
1. MkDocs (The Core)¶
We use the Material for MkDocs theme for its modern aesthetics and mobile responsiveness.
- Configuration:
mkdocs.yml - Key Plugins:
mkdocs-kroki-plugin: Renders diagrams (GraphViz, Mermaid, etc.).pymdown-extensions: Adds advanced Markdown features (Admonitions, Tabbed code blocks).- MkDocs Hooks: Custom Python scripts to extend MkDocs behavior.
2. Doxygen (The API)¶
We use the Doxygen Awesome CSS theme to make standard Doxygen output look modern and match the MkDocs style.
- Configuration:
Doxyfile - Customization:
HTML_EXTRA_STYLESHEETpoints to thedoxygen-awesome-cssfiles indocs/doxygen-awesome-css/.USE_MDFILE_AS_MAINPAGEis set todocs/api_index.mdto provide a clean landing page.- Math Compatibility: A Python input filter (
math_filter.py) automatically translates standard Markdown math for Doxygen. See Doxygen Customization for details.
🚀 Workflow¶
Local Development¶
To preview the full hybrid site locally:
Note:
make docs-dev(ormkdocs serve) only previews the MkDocs part and will NOT show the API reference.
Deployment (CI/CD)¶
The GitHub Actions workflow (.github/workflows/docs.yml) automates the deployment:
- Installs system deps (
doxygen,graphviz). - Builds MkDocs (
mkdocs build). - Builds Doxygen (
doxygen Doxyfile). - Deploys the combined
site/folder to thegh-pagesbranch.
🎨 Customization & Themes¶
Updating the MkDocs Theme¶
To change the MkDocs look (e.g., colors, fonts), edit mkdocs.yml:
theme:
name: material
palette:
primary: indigo # Change this to 'red', 'blue', 'teal', etc.
accent: deep purple
To switch to a completely different MkDocs theme (e.g., readthedocs):
- Install the theme (e.g.,
pip install mkdocs-readthedocs-theme). - Change
name: materialtoname: readthedocsinmkdocs.yml.
Updating the Doxygen Theme¶
To change the Doxygen look, you generally need to replace the CSS files.
- Doxygen Awesome: We include this as a git submodule (or vendored files) in
docs/doxygen-awesome-css. To update it,git pullin that directory. - Switching Themes:
- Comment out the
HTML_EXTRA_STYLESHEETlines inDoxyfileto revert to default Doxygen style. - Or download a new theme CSS, place it in
docs/, and updateHTML_EXTRA_STYLESHEET.
- Comment out the
🤖 Automated Diagram Indexing¶
To maintain a high-level overview of the engine's architecture, we use a custom MkDocs Hook to automatically index all Mermaid diagrams.
generate_diagram_index.py¶
This script (hooks/generate_diagram_index.py) runs during the on_config event of the MkDocs build process.
- Scanning: It parses all Markdown files in the
docs/directory. - Extraction: It extracts
mermaidcode blocks along with their preceding paragraph as a description. - Generation: It creates diagram_index.md.
- Interactive UI: The index features a "Tokyo Night" themed CSS hover effect that reveals a live preview of the diagram without leaving the page.
Configuration¶
The hook is registered in mkdocs.yml:
📊 Diagram Rendering (Suckless & Offline-First)¶
Nous suivons une philosophie zéro-dépendance externe. La documentation doit pouvoir être générée et consultée sans connexion internet.
Graphviz (Local-Only)¶
Plutôt que d'utiliser des services en ligne, nous utilisons un hook Python personnalisé (hooks/render_graphviz.py) qui invoque directement le binaire dot local :
- Rendu Local : Le hook intercepte les blocs
graphvizet appelle/usr/bin/dot. - Mise en Cache : Les SVGs générés sont stockés dans
docs/assets/diagrams/pour éviter des rendus inutiles. - Zéro Latence : Pas de requêtes réseau, rendu instantané et privé.
[!TIP] Pour vérifier que le build est réellement 100% offline, utilisez la commande :
Cette commande utilise
unshare -rnpour isoler totalement le processus du réseau. Ces cibles enchaînent automatiquementdocs-cleanetdocspour garantir un rendu à partir de zéro sans internet.[!IMPORTANT] L'installation de
graphvizest requise sur la machine de build pour générer ces diagrammes. Sidotest absent, le build MkDocs échouera explicitement via uneRuntimeError.
Mermaid (Browser-Side)¶
Les diagrammes Mermaid sont rendus directement par le navigateur via mermaid.js. Cela garantit que le rendu est toujours fidèle à la version du script embarquée, sans dépendre d'un serveur tiers ni de pré-génération complexe.
🧪 Documentation Integrity¶
We enforce documentation health through automated tests via scripts/verify_docs.py:
- Phase 1: Doxygen Diagrams: Ensures
\dotblocks are rendered as SVGs. - Phase 2: HTML Sanitization: Prevents raw HTML tags from appearing in navigation or escaped content.
- Phase 3: MkDocs Rendering: Scans for unrendered Mermaid/Graphviz blocks in the static
site/output. - Link Validation: test_docs_links.py ensures no broken internal links.