qmdc-mkdocs
Build documentation sites from QMDC workspaces using the MkDocs Material theme.
qmdc-mkdocs pre-renders QMD.md files (.qmd.md) into standard Markdown, then runs
MkDocs to produce a deployable static site. On top of Material it adds QMDC-specific
features:
- Graph sidebar — per-page breadcrumb, "links to", "linked from", and sibling navigation derived from the workspace reference graph.
- Semantic hints — popovers on object headings showing similar objects, from
pre-computed embeddings in
.qmdc-semantic/hints.json. - Dynamic SQL blocks —
```tablefenced blocks are executed against the workspace database and rendered as Markdown tables. - Reference links —
[[#id]]references become clickable links to the target object's page and anchor. - Mermaid diagrams —
```mermaidfences render at natural (readable) size and get a zoom/pan viewport with a toolbar (fit-to-width, actual size, zoom in/out; Ctrl/Cmd+wheel and drag to pan). Enabled automatically by the plugin — nomarkdown_extensionsconfig required. Mermaid is self-hosted (vendored into the site, no third-party CDN), so diagrams render offline / behind a CSP, and the theme follows Material's light/dark palette. The renderer core is shared verbatim with the VS Code preview (seemake mermaid-sync).
Full-text search is provided by MkDocs Material's built-in search plugin.
How it works
The tool uses the qmdc Python parser as a library (no qmdc binary): it parses
the workspace with qmdc.workspace.parse_workspace, loads objects and edges into an
in-memory SQLite database (qmdc.db.QmdcDatabase), and queries that locally for
reference resolution, the graph sidebar, and SQL blocks.
A build runs entirely in a temporary directory and leaves only the final HTML:
init → convert (internal) → mkdocs build → move HTML to _site/ → clean up tmp
The only file added to your workspace is mkdocs.yml (generated once, never
overwritten) plus the output directory.
Install
# From the monorepo root, with uv:
uv pip install -e ./qmdc-mkdocs
# Dev dependencies (pytest, ruff):
cd qmdc-mkdocs && uv sync --extra dev
Requires Python 3.12+. Runtime dependencies: qmdc, mkdocs>=1.6,
mkdocs-material>=9.5, click, pyyaml.
CLI
qmdc-mkdocs -w <workspace> <command>
--workspace/-w (default .) is the QMDC workspace root (a directory whose
readme.qmd.md declares [[id: __Workspace]]), or a namespace directory within
one — in which case the root is found automatically and only that namespace is built.
--output/-o (default <workspace>/_site) sets the output directory.
| Command | What it does |
|---|---|
init |
Generate mkdocs.yml (only if absent) and write a reference nav.yml to the workspace root. |
build |
Full pipeline: init → convert → mkdocs build, then move the HTML into the output directory. |
serve |
Same as build but runs mkdocs serve with live reload. --port (default 8000), --host (default 127.0.0.1). |
regenerate |
Regenerate ContentGenerator targets whose source objects changed. |
Examples:
qmdc-mkdocs -w ./docs build # build ./docs → ./docs/_site
qmdc-mkdocs -w ./docs -o /tmp/site build # custom output dir
qmdc-mkdocs -w ./docs serve --port 8800 # live preview
qmdc-mkdocs -w ./docs/storage build # build only the `storage` namespace
From the monorepo Makefile:
make mkdocs WS=./docs # build
make mkdocs-serve WS=./docs # serve (PORT=8800 by default)
make mkdocs-test # run this package's test suite
Plugin
The MkDocs plugin is registered as qmdc. To enable QMDC features in your own
mkdocs.yml, just add it to plugins:
plugins:
- search
- qmdc
The plugin injects its CSS/JS automatically (via on_config) and passes the graph
sidebar and semantic-hint data to the templates — you do not need to add anything to
extra_css/extra_javascript. All other build-time settings (docs_dir,
site_dir, theme.custom_dir) are injected automatically during build/serve.
hidden_kinds
To hide objects of certain kinds from the graph sidebar edges, add to the qmdc plugin
config in mkdocs.yml:
plugins:
- qmdc:
hidden_kinds: [Note, Draft]
Excluding files
Create a .qmdc-mkdocs.ignore file (gitignore-style, one pattern per line) in the
workspace root or any parent directory to exclude files from the site:
# Exclude an entire namespace
tracking/**
# Exclude SOP files everywhere
*.sop.qmd.md
Ignored files are excluded both as pages and from graph-sidebar edges.
Custom pages
- A plain
readme.mdnext to areadme.qmd.mdtakes priority and is copied unchanged as the directory index (no QMDC transformation). - Files under a
_pages/directory are copied into the build unchanged, so you can reference them from yournav:.
Custom theme / branding
Two layers, in increasing order of effort:
-
mkdocs.yml— the workspacemkdocs.ymlis passed through verbatim, so any MkDocs Material theming works out of the box:theme.palette(includingprimary: custom),theme.font,theme.logo,theme.favicon, light/dark toggle,extra_css,extra_javascript. This covers most branding (colors, fonts, logo). -
.mkdocs_theme/— an optional directory in the workspace root whose contents are overlaid onto the themecustom_dirat build time. Use it to ship the asset files yourmkdocs.ymlreferences, or to add extra partials/icons:<workspace>/ .mkdocs_theme/ css/brand.css # then: extra_css: [css/brand.css] in mkdocs.yml js/brand.js # then: extra_javascript: [js/brand.js] .icons/mybrand/… # custom icons for theme.logo / theme.icon mkdocs.ymlSafe precedence: the plugin's own templates (
main.html,partials/,css/qmdc-*,js/) are always applied last and win on name conflicts. You can freely add files, but you cannot replace the plugin's own files — so QMDC features (graph sidebar, Mermaid, hint popovers) can never be broken by a theme override. The directory is dot-prefixed, so it is never picked up as site content.
Development
cd qmdc-mkdocs
uv run --extra dev pytest -q # tests (also: `make mkdocs-test`)
uv run --extra dev ruff check . # lint
License
AGPL-3.0-or-later © mikilabs
Metadata
Release files for qmdc-mkdocs 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qmdc_mkdocs-2.0.1.tar.gz | 1.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qmdc_mkdocs-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.0 MB
Release files / qmdc_mkdocs-2.0.1.tar.gz
| Download URL | qmdc_mkdocs-2.0.1.tar.gz |
|---|---|
| Size | 1.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ed0956a45bdc02f37807316d0939334bbc9476e299cd5b93e655324d7d045f8
|
|
BLAKE2b-256 checksum How to use checksums |
cc3907656087455c4f1e82da2c8e3992fd2f90b6c54b8c23d3640fbbd24e2c67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / qmdc_mkdocs-2.0.1-py3-none-any.whl
| Download URL | qmdc_mkdocs-2.0.1-py3-none-any.whl |
|---|---|
| Size | 986.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7b4459687bcbaefe00cae0fbe1eca13961f25806ac6ec0dadf0239df6706b3f
|
|
BLAKE2b-256 checksum How to use checksums |
8a5ada805b50d1bf579d28ee66fb1e19895557f84d9a2574732aa8cb01e28e5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|