-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate.py
More file actions
executable file
·92 lines (75 loc) · 2.19 KB
/
generate.py
File metadata and controls
executable file
·92 lines (75 loc) · 2.19 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2022 Adobe
# All Rights Reserved.
#
# NOTICE: Adobe permits you to use, modify, and distribute this file in
# accordance with the terms of the Adobe license agreement accompanying
# it.
import subprocess
import argparse
from pathlib import Path
import shutil
def parse_args():
parser = argparse.ArgumentParser(description="Generate documentation for Lagrange.")
parser.add_argument("path", type=str, help="Path to lagrange repository")
parser.add_argument(
"--open",
action="store_true",
help="Prepare repo for open-source version of the website",
)
return parser.parse_args()
def prepare_open():
script_dir = Path(__file__).parent.resolve()
(script_dir / "mkdocs.yaml").unlink()
(script_dir / "mkdocs.open.yml").rename("mkdocs.yaml")
def main():
args = parse_args()
lagrange_dir = Path(args.path)
if not lagrange_dir.exists():
print("Path doesn't exist")
if args.open:
prepare_open()
script_dir = Path(__file__).parent.resolve()
is_corp = Path(script_dir / "mkdocs.open.yml").exists()
if is_corp:
docs_dir = str(script_dir / "docs")
else:
docs_dir = str(script_dir / "docs/open")
# Generates Doxygen C++ documentation
build_dir = script_dir / "build"
build_dir.mkdir(exist_ok=True)
subprocess.run(
[
"cmake",
"-B",
str(build_dir),
"-S",
str(lagrange_dir / "docs/cpp"),
"-DDOXYGEN_OUTPUT_DIR=" + docs_dir,
"-DDOXYGEN_OUTPUT_HTML=cpp",
],
check=True,
)
subprocess.run(
[
"cmake",
"--build",
str(build_dir),
"--target",
"doc",
],
check=True,
)
# Generates Sphinx Python documentation
subprocess.run(
["make", "-C", str(lagrange_dir / "docs/python"), "html"], check=True
)
shutil.copytree(
lagrange_dir / "docs/python/build/html",
Path(docs_dir) / "python",
dirs_exist_ok=True,
)
print("run `mkdocs serve` and open http://127.0.0.1:8000/")
if __name__ == "__main__":
main()