Skip to main content

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 — ```table fenced 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 — ```mermaid fences 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 — no markdown_extensions config 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 (see make 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.md next to a readme.qmd.md takes 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 your nav:.

Custom theme / branding

Two layers, in increasing order of effort:

  1. mkdocs.yml — the workspace mkdocs.yml is passed through verbatim, so any MkDocs Material theming works out of the box: theme.palette (including primary: custom), theme.font, theme.logo, theme.favicon, light/dark toggle, extra_css, extra_javascript. This covers most branding (colors, fonts, logo).

  2. .mkdocs_theme/ — an optional directory in the workspace root whose contents are overlaid onto the theme custom_dir at build time. Use it to ship the asset files your mkdocs.yml references, 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.yml
    

    Safe 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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qmdc-mkdocs 2.0.2
File Size Uploaded Provenance Actions
qmdc_mkdocs-2.0.2.tar.gz 1.0 MB Without provenance Details for qmdc_mkdocs-2.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qmdc-mkdocs 2.0.2
File Interpreter ABI Platform Actions
qmdc_mkdocs-2.0.2-py3-none-any.whl Python 3 none any Details for qmdc_mkdocs-2.0.2-py3-none-any.whl

Total release size: 2.0 MB

Release files / qmdc_mkdocs-2.0.2.tar.gz

Download URL qmdc_mkdocs-2.0.2.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
50cb009b4404951e008c8f6a90c13a250cb9853cf9d5835ecbac7f12dce1abbe
BLAKE2b-256 checksum
How to use checksums
0463f5d0285cd288344bee930386b078713208013ac17c3a4bfece5c31679d8a
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.2-py3-none-any.whl

Download URL qmdc_mkdocs-2.0.2-py3-none-any.whl
Size 986.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38cba7b3993035bd5d0ec80dc51aeaa932f19be58031911ba3cf63ac21fe77b7
BLAKE2b-256 checksum
How to use checksums
a8717debc04339871c81b89dfdca6ebf3f83589e61d2258eaca2e916a9533556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for qmdc-mkdocs 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page