Skip to content

Commit 878e21e

Browse files
committed
docs: trim dead config knobs and clarify the griffelib dependency
build_config's --site-dir/--output flags had no callers and contradicted the fixed site/ output contract; nav validation now skips external URLs, which are valid nav entries. The griffelib comment preempts the reasonable suspicion that the name is a typo for griffe.
1 parent 5464185 commit 878e21e

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ docs = [
9292
"mkdocstrings-python>=2.0.5",
9393
# scripts/docs/build_config.py and llms_txt.py read mkdocs.yml directly.
9494
"pyyaml>=6.0.2",
95+
# gen_ref_pages.py imports griffe directly. griffelib is not a typo: it is
96+
# griffe's successor distribution (same author) and still imports as
97+
# `griffe`; the old `griffe` distribution is the incompatible 1.x line.
9598
"griffelib>=2.1.0",
9699
]
97100
codegen = ["datamodel-code-generator==0.57.0"]

scripts/docs/build_config.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
"""Produce the concrete Zensical build config from ``mkdocs.yml``.
1+
"""Produce the concrete Zensical build config from `mkdocs.yml`.
22
3-
Zensical builds from ``mkdocs.yml`` directly, but it has no equivalent of
4-
``mkdocs-literate-nav``: the ``API Reference`` navigation has to be materialised
5-
as explicit entries. This script regenerates the ``docs/api/`` tree (via
6-
:mod:`gen_ref_pages`) and writes ``mkdocs.gen.yml`` with the real API nav
7-
spliced in — that generated file is what ``zensical build``/``serve`` consumes.
3+
Zensical builds from `mkdocs.yml` directly, but it has no equivalent of
4+
mkdocs-literate-nav: the "API Reference" navigation has to be materialised
5+
as explicit entries. This script regenerates the `docs/api/` tree (via
6+
gen_ref_pages) and writes `mkdocs.gen.yml` with the real API nav spliced
7+
in — that generated file is what `zensical build`/`serve` consumes.
88
99
Usage:
10-
python scripts/docs/build_config.py [--site-dir DIR] [--output FILE]
10+
python scripts/docs/build_config.py
1111
"""
1212

1313
from __future__ import annotations
1414

15-
import argparse
1615
from pathlib import Path
1716

1817
# Both scripts live in this directory, which Python puts on sys.path[0] when
@@ -36,12 +35,12 @@ def _missing_nav_pages(nav: list, docs_dir: Path) -> list[str]:
3635
value = next(iter(entry.values())) if isinstance(entry, dict) else entry
3736
if isinstance(value, list):
3837
missing.extend(_missing_nav_pages(value, docs_dir))
39-
elif not (docs_dir / value).is_file():
38+
elif "://" not in value and not (docs_dir / value).is_file():
4039
missing.append(value)
4140
return missing
4241

4342

44-
def build_config(output: Path, site_dir: str | None = None) -> None:
43+
def build_config() -> None:
4544
config = yaml.safe_load((ROOT / "mkdocs.yml").read_text(encoding="utf-8"))
4645

4746
api_nav = gen_ref_pages.generate()
@@ -57,19 +56,9 @@ def build_config(output: Path, site_dir: str | None = None) -> None:
5756
if missing := _missing_nav_pages(config["nav"], ROOT / "docs"):
5857
raise SystemExit(f"build_config: nav references pages that don't exist under docs/: {missing}")
5958

60-
if site_dir is not None:
61-
config["site_dir"] = site_dir
62-
59+
output = ROOT / "mkdocs.gen.yml"
6360
output.write_text(yaml.safe_dump(config, sort_keys=False, allow_unicode=True), encoding="utf-8")
6461

6562

66-
def main() -> None:
67-
parser = argparse.ArgumentParser(description=__doc__)
68-
parser.add_argument("--site-dir", default=None, help="Override the build output directory.")
69-
parser.add_argument("--output", default=str(ROOT / "mkdocs.gen.yml"), help="Where to write the generated config.")
70-
args = parser.parse_args()
71-
build_config(Path(args.output), args.site_dir)
72-
73-
7463
if __name__ == "__main__":
75-
main()
64+
build_config()

0 commit comments

Comments
 (0)