forked from NVIDIA/cuda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_docs.sh
More file actions
executable file
·53 lines (42 loc) · 1.8 KB
/
build_docs.sh
File metadata and controls
executable file
·53 lines (42 loc) · 1.8 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
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
set -ex
if [[ "$#" == "0" ]]; then
LATEST_ONLY="0"
elif [[ "$#" == "1" && "$1" == "latest-only" ]]; then
LATEST_ONLY="1"
else
echo "usage: ./build_docs.sh [latest-only]"
exit 1
fi
# SPHINX_CUDA_PYTHON_VER is used to create a subdir under build/html
# (the Makefile file for sphinx-build also honors it if defined).
# If there's a post release (ex: .post1) we don't want it to show up in the
# version selector or directory structure.
if [[ -z "${SPHINX_CUDA_PYTHON_VER}" ]]; then
export SPHINX_CUDA_PYTHON_VER=$(python -c "from importlib.metadata import version; \
ver = '.'.join(str(version('cuda-python')).split('.')[:3]); \
print(ver)" \
| awk -F'+' '{print $1}')
fi
# build the docs (in parallel)
SPHINXOPTS="-j 4 -d build/.doctrees" make html
# for debugging/developing (conf.py), please comment out the above line and
# use the line below instead, as we must build in serial to avoid getting
# obsecure Sphinx errors
#SPHINXOPTS="-v" make html
# to support version dropdown menu
cp ./versions.json build/html
# to have a redirection page (to the latest docs)
cp source/_templates/main.html build/html/index.html
# ensure that the latest docs is the one we built
if [[ $LATEST_ONLY == "0" ]]; then
cp -r build/html/${SPHINX_CUDA_PYTHON_VER} build/html/latest
else
mv build/html/${SPHINX_CUDA_PYTHON_VER} build/html/latest
fi
# ensure that the Sphinx reference uses the latest docs
cp build/html/latest/objects.inv build/html
# clean up previously auto-generated files
rm -rf source/generated/