-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocument.py
43 lines (33 loc) · 1.05 KB
/
document.py
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
# document.py
import os
from pathlib import Path
from base import validate_requirement
def generate_html(
package: str,
destination: str = None,
reload: bool = False,
show: bool = False
) -> None:
"""
Generates the documentation for the package.
:param reload: The value to rewrite the documentation.
:param show: The value to show the documentation.
:param package: The package to document.
:param destination: The documentation destination.
"""
validate_requirement("pdoc", path="pdoc3")
from pdoc.cli import main as document, parser
if destination is None:
destination = "docs"
main_index_file = Path(destination) / Path(package) / Path("index.html")
if reload or not main_index_file.is_dir():
document(
parser.parse_args(
[
"--html", "--force", "--output-dir",
str(destination), str(package)
]
)
)
if show:
os.system(f'start {main_index_file}')