Skip to main content

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 Discussions 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 PyUp

Read the completely coded documentation!

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

To build a full website from MkNodes, use the site generator mkdocs-mknodes (builds with Zensical). MkNodes itself does not depend on MkDocs or any other site engine.

Quickstart

import asyncio

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(asyncio.run(page.to_markdown()))

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: MkNav sections with decorator-based routing, API docs via MkDoc, CLI docs via MkCliNav, or parse an existing SUMMARY.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: /// mknodes blocks and executable Python code blocks (mknodes.mdext).

Build a website tree

import mknodes as mk


def build(root: mk.MkNav) -> 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()

Render it to a folder of Markdown files with the CLI (run inside your project's repository):

mknodes build -s mypackage.docs:build -o docs

or build a complete website with mkdocs-mknodes (mkdocs-mknodes build), configured in pyproject.toml:

[tool.mknodes]
build-fn = "mypackage.docs:build"

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 3.2.1

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

Source distribution (sdist)

Source distribution for mknodes 3.2.1
File Size Uploaded Provenance Actions
mknodes-3.2.1.tar.gz 368.7 kB Without provenance Details for mknodes-3.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 846.2 kB

Release files / mknodes-3.2.1.tar.gz

Download URL mknodes-3.2.1.tar.gz
Size 368.7 kB
Tags Source
SHA-256 checksum
How to use checksums
faef318d7f43573189b5923a52d7f71ee0eee90cf183085d097c354d2c387e9f
BLAKE2b-256 checksum
How to use checksums
9e54b7265ee60961e9e8575def3909117e2273b16a2e4b78de6bf7e8ffa2655e
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 / mknodes-3.2.1-py3-none-any.whl

Download URL mknodes-3.2.1-py3-none-any.whl
Size 477.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95633def9d5682fe0e8a5707cd9cd7b0e2cb7b31a100bfed1759cec3aa6a12c8
BLAKE2b-256 checksum
How to use checksums
98c51f3428db2cf4b7305ea8f52ad4c6441df0f49dcffc1ab66fb77aadfc62e2
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 mknodes 3.2.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.

Release history Release notifications | RSS feed

This release

3.2.1 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