-
Notifications
You must be signed in to change notification settings - Fork 245
/
build_docs.py
37 lines (26 loc) · 1.28 KB
/
build_docs.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
# Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved.
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
import os
import shutil
import subprocess
from warp.context import export_functions_rst, export_stubs
base_path = os.path.dirname(os.path.realpath(__file__))
# generate stubs for autocomplete
with open(os.path.join(base_path, "warp", "stubs.py"), "w") as stub_file:
export_stubs(stub_file)
# code formatting of stubs.py
subprocess.run(["ruff", "format", "--verbose", os.path.join(base_path, "warp", "stubs.py")])
with open(os.path.join(base_path, "docs", "modules", "functions.rst"), "w") as function_ref:
export_functions_rst(function_ref)
source_dir = os.path.join(base_path, "docs")
output_dir = os.path.join(base_path, "docs", "_build", "html")
# Clean previous HTML output
if os.path.exists(output_dir):
shutil.rmtree(output_dir)
command = ["sphinx-build", "-W", "-b", "html", source_dir, output_dir]
subprocess.run(command, check=True)
print("Finished")