Overview
The diagram generator (diagram-gen/generate.py) scans all mintdocs/**/*.mdx files for mermaid code blocks, extracts each block to a .mmd source file in diagram-gen/sources/, and renders each source to a PNG in mintdocs/images/diagrams/.
Both the .mmd source files and the rendered PNGs are committed to the repo.
Prerequisites
Node.js must be installed. Install the Mermaid CLI globally:Running the generator
From the repo root, run to render only changed or new diagrams:How incremental rendering works
On each run the generator:- Extracts all mermaid blocks from every
.mdxfile and writes them to.mmdsource files. - Tracks which
.mmdfiles had their content change compared to the previously committed version. - Renders only the diagrams whose source changed or whose PNG is missing.
- Stages all generated
.mmdand.pngfiles withgit addso the pre-commit hook picks them up cleanly.
--force when you need to regenerate everything — for example after changing the render width or background settings in generate.py.
Authoring diagrams
Follow the rules in the AGENTS.md diagram section exactly. In summary:- Add a mermaid fenced code block to the MDX page:
- Immediately after the closing fence, add a
<Frame>thumbnail:
- Run the generator to produce the PNG:
Naming convention
| File | Pattern |
|---|---|
| Source | diagram-gen/sources/{mdx-stem}--diagram-{n}.mmd |
| PNG | mintdocs/images/diagrams/{mdx-stem}--diagram-{n}.png |
{mdx-stem} is the MDX filename without extension and without the folder prefix. {n} is the 1-based index of the diagram on that page.
Example — second diagram in architecture/architecture-overview.mdx:
- Source:
diagram-gen/sources/architecture-overview--diagram-2.mmd - PNG:
mintdocs/images/diagrams/architecture-overview--diagram-2.png
Pre-commit hook
The.pre-commit-config.yaml at the repo root runs generate.py --check automatically before every commit that touches .mdx files. The check mode exits with code 1 if any .mmd source is out of date, prompting you to run the generator before committing.
Install the hook once from the repo root:
