docs_links.py
Repair cross-document links in the rendered site, then assert none are left broken.
Overview
Repair cross-document links in the rendered site, then assert none are left broken.
The guide pages are authored as markdown that must also read correctly on GitHub,
so they link to other documents as other.md and to sources as ../modules/x.c.
Neither form resolves once the pages are rendered into site/:
* `other.md` -> `other.html`, when that page was rendered * `../modules/x.c` -> the file on GitHub, since sources are not published
Anything still unresolved after the rewrite is a genuine broken link and fails the build. Run from the repo root, after both generators.
flowchart TD blob_base --> git
API
Fblob_base() -> str
github.com/<owner>/<repo>/blob/<branch> for the current remote, or '' if none.
main · calls gitF_entries(directory: Path) -> dict[str, str]
{lowercased name: real name} for a directory, cached. macOS is
case-insensitive, so Path.exists() happily confirms ARCHITECTURE.html
when the file on disk is architecture.html; a case-sensitive web host
then serves a 404. Every existence check here goes through this map so the
case a link claims is the case that actually exists.
_exact, _realF_real(path: Path) -> Path | None
path with the casing it actually has on disk, or None when absent.
fix · calls _entriesF_exact(path: Path) -> bool
True only when path exists with exactly this casing.
main · calls _entriesUndocumented (3)
git, main, fix