docs: add documentation versioning

This commit is contained in:
2026-03-11 15:03:20 -04:00
parent f82225f995
commit 1ee3a3a7e2
5 changed files with 145 additions and 22 deletions

60
scripts/mkdocs Executable file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env python3
"""mkdocs shim for mike compatibility.
mike parses mkdocs.yml (valid YAML stub) for its Python internals, then calls
`mkdocs build --config-file <mike-injected-temp.yml>` as a subprocess.
This shim intercepts that subprocess call, ignores the temp config, and
delegates the actual build to `zensical build -f zensical.toml` instead.
"""
from __future__ import annotations
import os
import subprocess
import sys
def main() -> None:
args = sys.argv[1:]
# mike calls `mkdocs --version` to embed in the commit message
if args and args[0] == "--version":
print("mkdocs, version 1.0.0 (zensical shim)")
return
if not args or args[0] != "build":
result = subprocess.run(["python3", "-m", "mkdocs"] + args)
sys.exit(result.returncode)
config_file = "mkdocs.yml"
clean = False
i = 1
while i < len(args):
if args[i] in ("-f", "--config-file") and i + 1 < len(args):
config_file = args[i + 1]
i += 2
elif args[i] in ("-c", "--clean"):
clean = True
i += 1
elif args[i] == "--dirty":
i += 1
else:
i += 1
# mike creates a temp file prefixed with "mike-mkdocs"; always delegate
# the actual build to zensical regardless of which config was passed.
del config_file # unused — zensical auto-discovers zensical.toml
cmd = ["zensical", "build"]
if clean:
cmd.append("--clean")
env = os.environ.copy()
result = subprocess.run(cmd, env=env)
sys.exit(result.returncode)
if __name__ == "__main__":
main()