File size: 1,657 Bytes
66c9c8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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 subprocess
import sys

from warp.context import export_functions_rst, export_stubs

# docs

# disable sphinx color output
os.environ["NO_COLOR"] = "1"

base_path = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(base_path, "docs", "modules", "functions.rst"), "w") as function_ref:
    export_functions_rst(function_ref)

# run Sphinx build
try:
    docs_folder = os.path.join(base_path, "docs")
    make_html_cmd = ["make.bat" if os.name == "nt" else "make", "html"]

    if os.name == "nt" or len(sys.argv) == 1:
        subprocess.check_output(make_html_cmd, cwd=docs_folder)
    else:
        # Sphinx options were passed via the argument list
        make_html_cmd.append("-e")
        sphinx_options = " ".join(sys.argv[1:])
        subprocess.check_output(make_html_cmd, cwd=docs_folder, env=dict(os.environ, SPHINXOPTS=sphinx_options))
except subprocess.CalledProcessError as e:
    print(e.output.decode())
    raise e

# generate stubs for autocomplete
with open(os.path.join(base_path, "warp", "stubs.py"), "w") as stub_file:
    export_stubs(stub_file)

# code formatting
subprocess.run([sys.executable, "-m", "black", os.path.join(base_path, "warp", "stubs.py")])

print("Finished")