MkNodes (MkDocs plugin)
Don't write docs. Code them.
mkdocs-mknodes is a MkDocs plugin that 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.
Installation
pip install mkdocs-mknodes
Quickstart
1. Zero configuration: the default website
Add the plugin to mkdocs.yml without any options:
site_name: My project
theme:
name: material
plugins:
- mknodes
Then build:
mkdocs-mknodes build # or: mkdocs build / mkdocs serve
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, MkDocs plugin flow (for MkDocs plugins) 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 (next to mkdocs.yml)
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)
plugins:
- 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 YAML
The default build function also accepts a node tree written in YAML:
plugins:
- mknodes:
kwargs:
pages:
- title: Home
type: MkText
text: "{{ metadata.description }}"
is_index: true
- title: API
type: MkDoc
section_name: API
recursive: true
- Development:
- title: Changelog
type: MkChangelog
- title: License
type: MkLicense
Features
- Hooks into the regular MkDocs build: pages, navigation, CSS/JS resources and required Markdown extensions are collected from the node tree and added to the MkDocs config automatically.
- 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; links between pages are resolved automatically.
- Edit-page links point to the code that generated a page;
show_page_info: trueappends build information (metadata, resources, generating code) to every page. - Optional rewriting of MkDocs-Material templates for extra features (iconify icons,
per-page
navigation.indexes/navigation.expand). - Build documentation for remote repositories (
repo_pathcan be a Git URL). - A CLI (
mkdocs-mknodes build | serve | create-config) closely aligned with the MkDocs CLI, with rich logging output.
CLI
# build the site for the current repository using mkdocs.yml
mkdocs-mknodes build
# build docs for a remote repository with a different config and output dir
mkdocs-mknodes build -r https://github.com/mkdocs/mkdocs.git -p configs/mkdocs_mkdocs.yml -d site/mkdocs
# live preview
mkdocs-mknodes serve
# print a MkDocs config inferred from a build function and the project metadata
mkdocs-mknodes create-config
Run mkdocs-mknodes <command> --help for all options.
Plugin options
The most important settings (see the docs for all):
| Option | Default | Description |
|---|---|---|
build_fn |
mkdocs_mknodes:parse |
Callable that builds the node tree |
kwargs |
Keyword arguments for the build function (e.g. pages) |
|
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 all pages with Jinja |
build_folder |
temporary dir | Where generated Markdown files are written |
License
MIT
Metadata
Release files for mkdocs-mknodes 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mkdocs_mknodes-1.1.2.tar.gz | 55.4 kB | Without provenance | Details for mkdocs_mknodes-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mkdocs_mknodes-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for mkdocs_mknodes-1.1.2-py3-none-any.whl |
Total release size: 124.9 kB
Release files / mkdocs_mknodes-1.1.2.tar.gz
| Download URL | mkdocs_mknodes-1.1.2.tar.gz |
|---|---|
| Size | 55.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56d45aff6e5e488f3d6693d61397dc1f3615ce14129592437c7bec1a2fcaf5e5
|
|
BLAKE2b-256 checksum How to use checksums |
d612a18fcf657589a030aee56317669115180377789675da4ef5628927e2201e
|
| 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-1.1.2-py3-none-any.whl
| Download URL | mkdocs_mknodes-1.1.2-py3-none-any.whl |
|---|---|
| Size | 69.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf101759d9aa6b2d9b617ed6e775a13538c6f321a0c513ef00a7e8860f1763fd
|
|
BLAKE2b-256 checksum How to use checksums |
e9fd59f78652d3172ea54479bc4515861dd936f716502ea4b0791a94c9417794
|
| 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 1.1.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.