Skip to content

Configuration

Settings are read from (later sources win):

  1. the mknodes entry of the plugins list in mkdocs.yml (kept for existing sites),
  2. [tool.mknodes] in pyproject.toml (preferred, - and _ are interchangeable),
  3. CLI options (--build-fn, --repo-url, --clone-depth, --generated-dir, ...).

Without any settings, the default website gets generated.

[tool.mknodes]
build-fn = "docs/build.py:build"
show-page-info = true
global-resources = false

Info

MkNodes writes HTML template overrides (announcement bars, per-page resources, the error page, ...) into the theme custom_dir (default: overrides). That folder must be placed outside of the docs/ dir. Generated files are listed in a .gitignore inside the folders they get written to, hand-written files are never overwritten.

Available settings:

Settings for generating a website from a MkNodes build function.

Parameters:

Name Type Description Default
project_dir Path

Return a new path pointing to the current working directory.

PosixPath('/home/runner/work/mkdocs-mknodes/mkdocs-mknodes')
config_file Path | None

The site config the generated config inherits from (mkdocs.yml).

None
build_fn str

Build function (module:callable, path/file.py:callable, module:Class.method).

'mkdocs_mknodes:parse'
kwargs dict[str, Any]

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
repo_path str

Repository to build docs for (local path or remote URL).

'.'
clone_depth int

Clone depth for remote repositories.

100
show_page_info bool

Append a collapsible box with build info to every page.

False
render_by_default bool

Render generated pages with the MkNodes Jinja environment.

True
global_resources bool

Put CSS / JS into the site config instead of per-page template blocks.

True
docs_dir str | None

Docs folder (default: docs_dir of the site config, else docs).

None
generated_dir str | None

Folder to write generated pages into (default: docs_dir).

If it differs from docs_dir, hand-written pages get mirrored into it and it becomes the docs dir of the generated config.

None
generated_config str

Filename of the generated site config (relative to the project dir).

'mkdocs.generated.yml'
site_dir str | None

Output folder for the HTML build (default: the site config's site_dir).

None
jinja_loaders list[dict[str, Any]] | None
None
jinja_extensions list[str] | None
None
jinja_block_start_string str | None
None
jinja_block_end_string str | None
None
jinja_variable_start_string str | None
None
jinja_variable_end_string str | None
None
site_config dict[str, Any]

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>

build_fn class-attribute instance-attribute

build_fn: str = paths.DEFAULT_BUILD_FN

Build function (module:callable, path/file.py:callable, module:Class.method).

clone_depth class-attribute instance-attribute

clone_depth: int = 100

Clone depth for remote repositories.

config_file class-attribute instance-attribute

config_file: Path | None = None

The site config the generated config inherits from (mkdocs.yml).

docs_dir class-attribute instance-attribute

docs_dir: str | None = None

Docs folder (default: docs_dir of the site config, else docs).

generated_config class-attribute instance-attribute

generated_config: str = GENERATED_CONFIG

Filename of the generated site config (relative to the project dir).

generated_config_path property

generated_config_path: Path

generated_dir class-attribute instance-attribute

generated_dir: str | None = None

Folder to write generated pages into (default: docs_dir).

If it differs from docs_dir, hand-written pages get mirrored into it and it becomes the docs dir of the generated config.

global_resources class-attribute instance-attribute

global_resources: bool = True

Put CSS / JS into the site config instead of per-page template blocks.

jinja_block_end_string class-attribute instance-attribute

jinja_block_end_string: str | None = None

jinja_block_start_string class-attribute instance-attribute

jinja_block_start_string: str | None = None

jinja_extensions class-attribute instance-attribute

jinja_extensions: list[str] | None = None

jinja_loaders class-attribute instance-attribute

jinja_loaders: list[dict[str, Any]] | None = None

jinja_variable_end_string class-attribute instance-attribute

jinja_variable_end_string: str | None = None

jinja_variable_start_string class-attribute instance-attribute

jinja_variable_start_string: str | None = None

kwargs class-attribute instance-attribute

kwargs: dict[str, Any] = dataclasses.field(default_factory=dict)

Keyword arguments for the build function (pages for the default build function).

project_dir class-attribute instance-attribute

project_dir: Path = dataclasses.field(default_factory=pathlib.Path.cwd)

Root folder of the project (contains mkdocs.yml / pyproject.toml).

render_by_default class-attribute instance-attribute

render_by_default: bool = True

Render generated pages with the MkNodes Jinja environment.

repo_path class-attribute instance-attribute

repo_path: str = '.'

Repository to build docs for (local path or remote URL).

resolved_docs_dir property

resolved_docs_dir: Path

resolved_generated_dir property

resolved_generated_dir: Path

show_page_info class-attribute instance-attribute

show_page_info: bool = False

Append a collapsible box with build info to every page.

site_config class-attribute instance-attribute

site_config: dict[str, Any] = dataclasses.field(default_factory=dict, repr=False)

The loaded site config (INHERIT resolved, custom tags preserved).

site_dir class-attribute instance-attribute

site_dir: str | None = None

Output folder for the HTML build (default: the site config's site_dir).

theme_config property

theme_config: dict[str, Any]

__init__

__init__(
    project_dir: Path = cwd(),
    config_file: Path | None = None,
    build_fn: str = DEFAULT_BUILD_FN,
    kwargs: dict[str, Any] = dict(),
    repo_path: str = ".",
    clone_depth: int = 100,
    show_page_info: bool = False,
    render_by_default: bool = True,
    global_resources: bool = True,
    docs_dir: str | None = None,
    generated_dir: str | None = None,
    generated_config: str = GENERATED_CONFIG,
    site_dir: str | None = None,
    jinja_loaders: list[dict[str, Any]] | None = None,
    jinja_extensions: list[str] | None = None,
    jinja_block_start_string: str | None = None,
    jinja_block_end_string: str | None = None,
    jinja_variable_start_string: str | None = None,
    jinja_variable_end_string: str | None = None,
    site_config: dict[str, Any] = dict(),
) -> None

get_builder

get_builder() -> Callable[..., Any]

Return the build function with the configured kwargs bound.

get_jinja_config

get_jinja_config() -> EnvConfig

load classmethod

load(
    project_dir: str | PathLike[str] | None = None,
    config_file: str | PathLike[str] | None = None,
    **overrides: Any
) -> GeneratorSettings

Load settings for given project.

Parameters:

Name Type Description Default
project_dir str | PathLike[str] | None

Project root (default: cwd, or the folder of config_file)

None
config_file str | PathLike[str] | None

Site config to read (default: mkdocs.yml in the project dir)

None
overrides Any

Explicit setting overrides (None values are ignored)

{}
Page info
Code for this page
mkdocs_mknodes.manual.get_started_section._
@router.route_page("Configuration", hide="toc")
def _(page: mk.MkPage):
    page += mk.MkTemplate("configuration.jinja")
    page += mk.MkDocStrings(
        "mkdocs_mknodes.generator.settings.GeneratorSettings",
        show_root_toc_entry=False,
        show_if_no_docstring=True,
        heading_level=4,
        show_bases=False,
        show_source=False,
    )
Resources
Resources(css=[],
          markdown_extensions={},
          plugins=[Plugin('mkdocstrings')],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mkdocs-mknodes/mkdocs-mknodes/mkdocs_mknodes/manual/root.py
  source_function: Build.on_root
  source_line_no: 24
hide:
- toc
title: Configuration