mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-04-16 06:36:26 +02:00
docs: add documentation versioning
This commit is contained in:
60
scripts/mkdocs
Executable file
60
scripts/mkdocs
Executable 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()
|
||||
Reference in New Issue
Block a user