Skip to main content

MkDocs-MkNodes

Don't write docs. Code them.

PyPI License Package status Daily downloads Weekly downloads Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Forks Github Issues Github Issues Github Watchers Github Stars Github Repository size Github last commit Github release date Github language count Github commits this week Github commits this month Github commits this year Package status

Read the documentation!

mkdocs-mknodes builds your documentation site from a Python node tree created with MkNodes. Pages, navigation, API docs, changelogs, dependency tables, diagrams and more are generated from your project's metadata and code, and you can still mix in hand-written Markdown and Jinja templates wherever you like. The HTML site is built by Zensical.

2.0: The MkDocs plugin is gone. MkNodes generates the site input (pages, nav, assets, config) and Zensical builds it. Existing mkdocs.yml files keep working: the mknodes entry of the plugins list is still read for settings, but [tool.mknodes] in pyproject.toml is the preferred place now.

Installation

pip install mkdocs-mknodes

Quickstart

1. Zero configuration: the default website

mkdocs-mknodes build   # generate + zensical build
mkdocs-mknodes serve   # live preview on http://localhost:8000/

A mkdocs.yml is optional (theme, site_name, markdown_extensions, ...). Without a build-fn or pages setting, MkNodes builds a complete default website for the project in the current Git repository:

  • Home: your README.md (falls back to .github/README.md, then the package description)
  • API: API reference for your package, generated recursively
  • CLI: CLI documentation, if your project defines a command line interface
  • Development: changelog (from Git commits), contribution guidelines, dev environment setup, dependency table and tree and license

2. Custom website: your own build function

Point build-fn to any callable (module:function, module:Class.classmethod or path/to/file.py:function). It receives the root MkNav and the theme and fills the tree:

# build_docs.py (in the project root)
import mknodes as mk


def build(root: mk.MkNav, theme: mk.Theme) -> None:
    page = root.add_page("Home", is_index=True)
    page += mk.MkAdmonition("Hello, world!")
    page += mk.MkCode.for_object(build)  # show the code that created this page
    root.add_doc(section_name="API", recursive=True)
# pyproject.toml
[tool.mknodes]
build-fn = "build_docs.py:build"

Build functions may also be async. Extra keyword arguments can be passed via the kwargs setting.

3. Custom website from config

The default build function also accepts a node tree via the pages setting:

[[tool.mknodes.pages]]
title = "Home"
type = "MkText"
text = "{{ metadata.description }}"
is_index = true

[[tool.mknodes.pages]]
title = "API"
type = "MkDoc"
section_name = "API"
recursive = true

[[tool.mknodes.pages]]
Development = [
  { title = "Changelog", type = "MkChangelog" },
  { title = "License", type = "MkLicense" },
]

How it works

mkdocs-mknodes generate runs the build function and writes

  • the generated pages and assets into the docs folder (listed in a generated docs/.gitignore; hand-written pages are never overwritten and keep working next to the generated ones),
  • HTML template overrides (announcement bars, per-page resources, error page, ...) into the theme custom_dir (default overrides/),
  • mkdocs.generated.yml, which INHERITs mkdocs.yml and adds the nav, the required Markdown extensions and extra CSS / JS.

mkdocs-mknodes build then runs zensical build -f mkdocs.generated.yml; serve runs generate --watch next to zensical serve.

Features

  • Project metadata (pyproject, Git, installed distribution, ...) is available to all nodes and to the built-in Jinja environment (powered by JinjaRope).
  • Pages can be Jinja templates; bare links between generated pages are resolved automatically.
  • Edit-page links point to the code that generated a page; show-page-info = true appends build information (metadata, resources, generating code) to every page.
  • Build documentation for remote repositories (--repo-url can be a Git URL).

CLI

mkdocs-mknodes generate [--watch]       # only write the site input
mkdocs-mknodes build [-d site] [-s]     # generate + zensical build (strict mode with -s)
mkdocs-mknodes serve                    # generate --watch + zensical serve
mkdocs-mknodes build -r https://github.com/owner/repo.git   # docs for a remote repository

--engine zensical / -e zensical is accepted for compatibility (Zensical is the only engine). Run mkdocs-mknodes <command> --help for all options.

Settings

Read from [tool.mknodes] in pyproject.toml (preferred) and the mknodes entry of the plugins list in mkdocs.yml (pyproject.toml wins, CLI options win over both). The most important settings (see the docs for all):

Setting Default Description
build-fn mkdocs_mknodes:parse Callable that builds the node tree
kwargs Keyword arguments for the build function
pages Node tree for the default build function
repo-path . Local path or Git URL of the repository to document
clone-depth 100 Clone depth for remote repositories
show-page-info false Append build information to every page
global-resources true Put CSS/JS into all pages instead of only the pages that need them
render-by-default true Render generated pages with Jinja
generated-dir docs dir Where generated pages are written

Migrating from 1.x

  • Build with mkdocs-mknodes build (--engine zensical still works), not mkdocs build.
  • mkdocs is no longer a dependency; add zensical (pulled in by mkdocs-mknodes) and keep mkdocstrings[python] in your docs dependencies for API pages.
  • Removed: the MkDocs plugin (mkdocs.plugins entry point), create-config, the --theme and --use-directory-urls options, the Jinja rendering of hand-written pages, the link replacer for hand-written pages and the MkDocs template rewriting. The plugin options build_folder, rewrite_theme_templates, auto_delete_generated_templates, jinja_on_undefined and llm_* are ignored.

License

MIT

Metadata

Release files for mkdocs-mknodes 2.0.0

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

Source distribution (sdist)

Source distribution for mkdocs-mknodes 2.0.0
File Size Uploaded Provenance Actions
mkdocs_mknodes-2.0.0.tar.gz 38.7 kB Without provenance Details for mkdocs_mknodes-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-mknodes 2.0.0
File Interpreter ABI Platform Actions
mkdocs_mknodes-2.0.0-py3-none-any.whl Python 3 none any Details for mkdocs_mknodes-2.0.0-py3-none-any.whl

Total release size: 81.8 kB

Release files / mkdocs_mknodes-2.0.0.tar.gz

Download URL mkdocs_mknodes-2.0.0.tar.gz
Size 38.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4eaa3247ce7a23a50760f84d0942585fcd25821cdbcdfc77b7b574be6d781c56
BLAKE2b-256 checksum
How to use checksums
8f7b010b03fe973e843c62913120c73b354879b53b058de6fef77cc5577e074c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mkdocs_mknodes-2.0.0-py3-none-any.whl

Download URL mkdocs_mknodes-2.0.0-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d2f01a7de8b7f993a14c35c68f20e380ee6377db1627fcf09c3e6a41d3aa362
BLAKE2b-256 checksum
How to use checksums
6e853c9f71df55f84cd62c2ca1e0babaf0a204dc4437e872606d6f98716863e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for mkdocs-mknodes 2.0.0

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.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

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