python file to generate docs. useful for pycharm on windows
This commit is contained in:
46
generate_docs.py
Normal file
46
generate_docs.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
"""
|
||||||
|
Programmatic MkDocs build script for OmniRead.
|
||||||
|
|
||||||
|
This script builds (or serves) the documentation by invoking MkDocs
|
||||||
|
*as a Python library*, not via shell commands.
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
- mkdocs
|
||||||
|
- mkdocs-material
|
||||||
|
- mkdocstrings[python]
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python generate_docs.py
|
||||||
|
python generate_docs.py --serve
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from mkdocs.commands import build as mkdocs_build
|
||||||
|
from mkdocs.commands import serve as mkdocs_serve
|
||||||
|
from mkdocs.config import load_config
|
||||||
|
|
||||||
|
|
||||||
|
PROJECT_ROOT = Path(__file__).resolve().parent
|
||||||
|
MKDOCS_YML = PROJECT_ROOT / "mkdocs.yml"
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
if not MKDOCS_YML.exists():
|
||||||
|
raise FileNotFoundError("mkdocs.yml not found at project root")
|
||||||
|
|
||||||
|
# Load MkDocs configuration programmatically
|
||||||
|
config = load_config(str(MKDOCS_YML))
|
||||||
|
|
||||||
|
# Decide mode
|
||||||
|
if "--serve" in sys.argv:
|
||||||
|
# Live-reload development server
|
||||||
|
mkdocs_serve.serve(config)
|
||||||
|
else:
|
||||||
|
# Static site build
|
||||||
|
mkdocs_build.build(config)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user