-
Notifications
You must be signed in to change notification settings - Fork 312
Expand file tree
/
Copy pathbuild_docs.sh
More file actions
executable file
·58 lines (46 loc) · 1.73 KB
/
Copy pathbuild_docs.sh
File metadata and controls
executable file
·58 lines (46 loc) · 1.73 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
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -ex
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
cd "${SCRIPT_DIR}"
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_CORE_VER is used to create a subdir under build/html
# (the Makefile file for sphinx-build also honors it if defined)
if [[ -z "${SPHINX_CUDA_CORE_VER}" ]]; then
export SPHINX_CUDA_CORE_VER=$(python -c "from importlib.metadata import version; print(version('cuda-core'))" \
| awk -F'+' '{print $1}')
fi
if [[ "${LATEST_ONLY}" == "1" && -z "${BUILD_PREVIEW:-}" && -z "${BUILD_LATEST:-}" ]]; then
export BUILD_LATEST=1
fi
# build the docs. Allow callers to override SPHINXOPTS for serial/debug runs.
if [[ -z "${SPHINXOPTS:-}" ]]; then
HTML_SPHINXOPTS="-W --keep-going -j 4 -d build/.doctrees"
else
HTML_SPHINXOPTS="${SPHINXOPTS}"
fi
SPHINXOPTS="${HTML_SPHINXOPTS}"
make html
# to support version dropdown menu
cp ./versions.json build/html
cp ./nv-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_CORE_VER} build/html/latest
else
mv build/html/${SPHINX_CUDA_CORE_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/