This repository standardises on PlantUML for all diagrams. The setup gives us:
- On-brand styling (EKGF blue/orange, Roboto, hand-drawn lines)
- Automatic light/dark variants (including white labels in dark mode)
- Clickable SVG links that keep working inside MkDocs
- Transparent backgrounds and responsive sizing without any manual tweaks
The sections below describe how everything fits together and how to add or update diagrams in the future.
docs/
├── diagrams/
│ ├── include/ # Shared PlantUML themes
│ │ ├── light.puml # Light palette
│ │ ├── dark.puml # Dark palette
│ │ └── general.puml # Style primitives used by both themes
│ ├── src/ # Author your *.puml files here
│ └── out/ # Auto-generated SVGs (never edit manually)
│
├── fragment/ # Reusable Markdown snippets that embed diagrams
└── stylesheets/extra.css # Layout tweaks (left align, spacing, etc.)
mkdocs.yml enables the mkdocs-build-plantuml plugin. When you run:
uv run mkdocs serve # or `uv run mkdocs build` or `gmake docs-serve`the plugin renders every docs/diagrams/src/*.puml file to an SVG pair
(light + dark) inside docs/diagrams/out/. Never commit hand-edited SVGs.
-
Add a Markdown fragment (or inline block) that wraps the SVG with an HTML
<object>, not the usual![]()syntax.
Example (docs/fragment/uctm-diagram-persona.md):<figure markdown> <object data="/diagrams/out/uctm-persona.svg#darkable" type="image/svg+xml"> </object> </figure>
- The
#darkablesuffix tells Material/MkDocs that both light and dark SVGs exist (foo.svg+foo_dark.svg). - Using
<object>keeps all SVG hyperlinks clickable (essential for cross-linking class diagrams to concept pages).
- The
-
Insert the fragment wherever you need it:
--8<-- "fragment/uctm-diagram-persona.md"
We load docs/javascripts/darkable-objects.js via extra_javascript. The
script performs the following on every page load (and when Material’s instant
navigation swaps content):
- Finds every
<object ... #darkable>element. - Fetches both SVG variants and inlines the markup directly into the page.
- Keeps all hyperlinks working.
- Ensures backgrounds remain transparent.
- Detects the current theme (light or dark) and swaps in the appropriate SVG whenever the palette toggle changes.
- Reads the SVG’s natural width (from
viewBox/width) and sets a responsive width capped atmin(natural width, viewport - 64px, 1400px).- Huge diagrams can stretch across large monitors.
- Smaller diagrams (like
Term) stay compact and never get blown up.
- Listens for window resize events and re-applies sizing with a short debounce.
Because of this script you should always embed diagrams using <object ... #darkable> — it is the trigger for everything above.
-
Author the PlantUML file under
docs/diagrams/src/. Every file should start with:@startuml !include ../include/themes/light.puml ... @enduml
- Use the shared theme; do not duplicate styling.
- For state/process diagrams, use
[ * ]start/end states — the dark theme now renders those nodes white so they remain visible at night.
-
Serve or build the docs.
mkdocs-build-plantumlwill emitdocs/diagrams/out/<filename>.svgand<filename>_dark.svg. -
Embed the generated SVG using the
<figure> + <object ... #darkable>pattern described above (ideally as a reusable fragment). -
Commit only the
.puml, fragment, and any Markdown/JS/CSS changes. Theout/folder is re-generated during builds.
-
Links not clickable?
Check that you used<object ... type="image/svg+xml">and thatdarkable-objects.jsis loaded (should happen automatically viamkdocs.yml). -
Diagram shows white box in dark mode?
Ensure your PlantUML file includes the shared theme, and confirm the fragment appends#darkableso the script can swap to<name>_dark.svg. -
Sizing looks odd?
Confirm the SVG has a correct@startuml/@endumlstructure. The script relies on PlantUML emitting a properviewBox. If you see issues, run a freshuv run mkdocs serveso the SVGs regenerate.
Following these steps keeps every diagram on-brand, accessible in both light and dark themes, and guarantees link-friendly, responsive SVGs throughout the site. Happy modelling!