Extras
Programmatically generating the navigation#
Reference: mkdocs_gen_files.Nav
#
An object representing MkDocs navigation, consisting of files under nested sequences of titles, which are treated like paths.
__setitem__(keys: str | tuple[str, ...], value: str)
#
Add a link to a file (value) into the nav, under the sequence of titles (keys).
For example, writing nav["Foo", "Bar"] = "foo/bar.md"
would mean creating a nav:
{"Foo": {"Bar": "foo/bar.md"}}
.
Then, writing nav["Foo", "Another"] = "test.md"
would merge with the existing sections
where possible:
{"Foo": {"Bar": "foo/bar.md", "Another": "test.md"}}
.
keys here can be any non-empty sequence of strings, it's just that Python implicitly creates a tuple from the comma-separated items in those square brackets.
items() -> Iterable[Item]
#
Allows viewing the nav as a flattened sequence.
build_literate_nav(indentation: int | str = '') -> Iterable[str]
#
Builds a file suitable for https://github.com/oprypin/mkdocs-literate-nav, as a sequence of lines to be written into a file.
For an example, see https://mkdocstrings.github.io/recipes/#generate-a-literate-navigation-file