MkNodes
Don't write docs. Code them.
Read the completely coded documentation!
The documentation is available in six variants:
| Variant | Engine / flavour |
|---|---|
| Zensical | --engine zensical (default), Material flavour |
| MkDocs | --engine mkdocs, Material for MkDocs |
| mdBook | --engine mdbook, mdBook flavour |
| Sphinx | --engine sphinx, MyST flavour (Furo theme) |
| Docsify | --engine docsify, GitHub flavour, rendered in the browser |
| GitHub Markdown | --engine markdown --flavor github, rendered by GitHub itself |
They are all generated from the same build function (mknodes.manual.root:Build.build):
the node tree is written once and each engine gets the Markdown flavour it understands.
MkNodes lets you build documentation from Python objects instead of hand-written Markdown. Pages, navigation sections and content blocks are nodes that render to Material for MkDocs-flavored Markdown and know which Markdown extensions, CSS and JavaScript they need. Many nodes pull their content directly from your project (pyproject.toml, git history, installed packages, docstrings), so the docs stay in sync with the code.
Installation
pip install mknodes
MkNodes includes a site generator (mknodes build / serve / generate) that builds
websites with Zensical (default), MkDocs
(pip install mknodes[mkdocs]), mdBook (the mdbook
binary), Sphinx with MyST (pip install mknodes[sphinx]) or
Docsify (no build step), or writes plain Markdown. MkDocs is not required. (The generator used to be the
separate mkdocs-mknodes package.)
Quickstart
import mknodes as mk
page = mk.MkPage("Overview")
page += mk.MkHeader("My project", level=1)
page += mk.MkAdmonition("Generated with MkNodes!", typ="tip", title="Note")
page += mk.MkTable({"Feature": ["Nodes", "Templating"], "Status": ["yes", "yes"]})
page += mk.MkCode("print('hello')", language="py")
print(page.to_markdown_sync()) # async code: `await page.to_markdown()`
print(page.to_markdown_sync(flavor="github")) # GitHub flavour (READMEs)
Features
- 75+ nodes: admonitions, tabs, tables, code blocks, diagrams, cards, timelines, badges, ...
- Project-aware nodes:
MkChangelog,MkInstallGuide,MkDependencyTable,MkLicense,MkShields,MkClassDiagram, ... build their content from your package and repository. - Navigation trees:
MkNavsections with decorator-based routing, API docs viaMkDoc, CLI docs viaMkCliNav, or parse an existingSUMMARY.md/ folder. - Jinja templating: every node is also a Jinja filter, e.g.
{{ "Inlined text" | MkAdmonition(inline="left") }}. - Resource tracking: required Markdown extensions, CSS and JS are collected per page.
- Markdown extensions:
/// mknodesblocks and executable Python code blocks (mknodes.mdext).
Build a website tree
import mknodes as mk
def build(root: mk.MkNav, theme: mk.Theme) -> None:
@root.route.page("Home", is_index=True)
def _(page: mk.MkPage):
page += mk.MkHeader("Welcome", level=1)
page += mk.MkInstallGuide()
@root.route.page("Changelog", icon="format-list-group")
def _(page: mk.MkPage):
page += mk.MkChangelog()
Configure it in pyproject.toml and build the website (run inside your project's repository):
[tool.mknodes]
build-fn = "mypackage.docs:build"
mknodes build # pages + mkdocs.generated.yml, then `zensical build`
mknodes serve # live preview
mknodes build --engine mkdocs # same input, built with MkDocs + Material
mknodes build --engine mdbook # book/ (book.toml, src/SUMMARY.md), then `mdbook build`
mknodes build --engine sphinx # sphinx/ (conf.py, MyST pages, toctrees), then `sphinx-build`
mknodes build --engine docsify # site/ (index.html, _sidebar.md, pages): no build step
mknodes generate --engine markdown --flavor github --generated-dir out # plain Markdown
Each engine renders its own Markdown flavour (material for Zensical / MkDocs, mdbook,
myst for Sphinx, github for Docsify and plain Markdown): admonitions, tabs, code blocks and API docs degrade to what the
target understands. See Site engines.
Without a build function, a default website gets generated (README, API docs, CLI docs,
development pages). Build functions are called as build_fn(root=..., theme=..., **kwargs)
(sync or async) and populate root.
The CLI also renders Jinja-enhanced Markdown: mknodes render -i template.md -o output.md
and mknodes render-folder -i src_docs -o docs.
Markdown extensions
import markdown
from mknodes.mdext.execute_ext import get_custom_fences
md = markdown.Markdown(
extensions=["pymdownx.superfences", "mknodes.mdext"],
extension_configs={"pymdownx.superfences": {"custom_fences": get_custom_fences()}},
)
/// mknodes
{{ "Dynamic Header" | MkHeader(level=2) }}
///
```python exec="true"
print("**Generated at build time!**")
```
Use session="name" on exec blocks to share variables between them. See
src/mknodes/mdext/README.md for all options.
Documentation
The documentation is itself built with MkNodes
(see src/mknodes/manual/) and shows every node with examples.
Metadata
Release files for mknodes 4.3.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 | Provenance | Actions |
|---|---|---|---|---|
| mknodes-4.3.1.tar.gz | 451.0 kB | Without provenance | Details for mknodes-4.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mknodes-4.3.1-py3-none-any.whl | Python 3 | none | any | Details for mknodes-4.3.1-py3-none-any.whl |
Total release size: 1.0 MB
Release files / mknodes-4.3.1.tar.gz
| Download URL | mknodes-4.3.1.tar.gz |
|---|---|
| Size | 451.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e264144b82a2be83d34579526ebbf4705f9b3515b1578ceeef55733fbcb60f1c
|
|
BLAKE2b-256 checksum How to use checksums |
87ed0eb36e8ddd169f8cb39dc58e6abb1dffb15cbb7cc6aef034a743c8ae9baa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 / mknodes-4.3.1-py3-none-any.whl
| Download URL | mknodes-4.3.1-py3-none-any.whl |
|---|---|
| Size | 579.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
881f21ac5aea3ed42552767c1ff8897f6316d56f6757cbab97049d4cf9ad60f6
|
|
BLAKE2b-256 checksum How to use checksums |
270effd24d78e7ae76d607326947d4777a12b282f7a37f96b106c3c31fb1d93c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 mknodes 4.3.1
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.