-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathpost-process.py
More file actions
34 lines (26 loc) · 891 Bytes
/
Copy pathpost-process.py
File metadata and controls
34 lines (26 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# MkDocs hook that runs the post-processing scripts (makeAppendices.py
# and make_indexall.py) before each build, so that the index, reference
# and appendix files are always up to date.
#
# Registered via the "hooks:" setting in mkdocs.yml (requires MkDocs >= 1.4).
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
SCRIPTS = (
"makeAppendices.py",
"make_indexall.py",
)
def on_pre_build(config: dict, **kwargs):
"""MkDocs hook: run the generator scripts before building the site."""
for name in SCRIPTS:
script_path = ROOT / name
if script_path.exists():
print(f"post-process: running {name}")
subprocess.run(
[sys.executable, str(script_path)],
check=True,
cwd=ROOT,
)
if __name__ == '__main__':
on_pre_build({})