Skip to content

Wiki

docforge.nav.wiki

Summary

Wiki navigation derivation.

This module provides build_wiki_nav, which derives an MkDocs-ready navigation block from the file structure of a hand-written wiki directory (typically docs/wiki). wiki content is authored by hand and is never modified by doc-forge; only the navigation layout is inferred.

Notes

  • index.md at the wiki root becomes the Home entry.
  • Page labels are derived from filenames: numeric order prefixes such as 01_ or 02- are stripped, separators are replaced with spaces, and names are title-cased (01_overview.md becomes Overview).
  • Subdirectories become nested navigation groups. A nested index.md is rendered as the section root placed first inside the group.
  • Only .md files are considered; hidden entries are ignored.

Functions

build_wiki_nav

build_wiki_nav(wiki_dir: Path) -> list[dict[str, Any]]

Derive an MkDocs navigation block from a wiki directory.

Returned paths are relative to the parent of wiki_dir and carry the wiki directory name as their leading component (for example wiki/01_overview.md when the wiki lives at docs/wiki). This makes the result directly usable in an MkDocs nav block with

  • index.md at the wiki root becomes the Home entry.
  • Page labels are derived from filenames: numeric order prefixes such as 01_ or 02- are stripped, separators are replaced with spaces, and names are title-cased (01_overview.md becomes Overview).
  • Subdirectories become nested navigation groups. A nested index.md is rendered as the section root placed first inside the group.
  • Only .md files are considered; hidden entries are ignored.

Parameters:

Name Type Description Default
wiki_dir Path

Path to the hand-written wiki directory, for example docs/wiki.

required

Returns:

Type Description
list[dict[str, Any]]

list[dict[str, Any]]: Navigation entries compatible with the MkDocs nav configuration. The list is empty if the wiki contains no Markdown files.

Raises:

Type Description
FileNotFoundError

If the wiki directory does not exist.