CLI

MkNodes offers a CLI to generate and build websites from MkNodes build functions.
The CLI is based on Typer and uses a rich based handler for nice, colored output.
Site generator commands:
-
mknodes generate: Runs the build function (or the default website) and writes the generated pages, assets and theme template overrides into the docs folder, plus a generated config (mkdocs.generated.yml, inheriting frommkdocs.yml) containing the nav, the required Markdown extensions and extra CSS / JS. With--watch, the site gets regenerated whenever project sources change. -
mknodes build:generate, followed byzensical build -f mkdocs.generated.yml. The build function can also run on a remote repository (--repo-url). -
mknodes serve:generate --watchrunning next tozensical serve(live preview on http://localhost:8000/).
Build diagnostics: problems that leave a page broken without stopping the build get logged as
warnings and summarized at the end of mknodes build / generate:
- a node that could not be created in a Jinja template
(
{{ "x" | MkAdmonition(nonsense=1) }}), - a failing
/// mknodesblock orpython exec="true"block (they run inside the engine, e.g. Zensical, and report back tomknodes build), - broken code fences in generated pages,
- unresolved
[title][identifier]references.
Each diagnostic names the page and where on it (line, template, first line of the block).
The error stays visible in the page for local work. With --strict (or strict = true in
[tool.mknodes]) the build fails if there was any diagnostic, which is what CI should use:
$ mknodes build --strict
ERROR Strict mode: 1 build diagnostics (1 exec):
usage.md (python exec block: from pkg import Thing): [exec] ImportError: ...
--strict is also passed to the engine (zensical build --strict --clean: pages from the
engine's cache would not run the Markdown extensions again). Diagnostics are also available
from Python: BuildOutput.diagnostics (see mknodes.utils.diagnostics).
Engines (--engine): zensical (default, HTML website), mkdocs, mdbook, sphinx,
docsify or markdown (plain Markdown files plus a SUMMARY.md nav, GitHub flavour), see
Site engines. --flavor overrides the Markdown flavour, see
Markdown flavours.
Other commands:
mknodes render: Render a single Markdown file with the MkNodes Jinja environment.mknodes render-folder: Render a folder of Markdown files (other files get copied).