|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 4 | +# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE |
| 5 | + |
| 6 | +set -ex |
| 7 | + |
| 8 | +if [[ "$#" == "0" ]]; then |
| 9 | + LATEST_ONLY="0" |
| 10 | +elif [[ "$#" == "1" && "$1" == "latest-only" ]]; then |
| 11 | + LATEST_ONLY="1" |
| 12 | +else |
| 13 | + echo "usage: ./build_docs.sh [latest-only]" |
| 14 | + exit 1 |
| 15 | +fi |
| 16 | + |
| 17 | +# SPHINX_CUDA_PATHFINDER_VER is used to create a subdir under build/html |
| 18 | +# (the Makefile file for sphinx-build also honors it if defined). |
| 19 | +# If there's a post release (ex: .post1) we don't want it to show up in the |
| 20 | +# version selector or directory structure. |
| 21 | +if [[ -z "${SPHINX_CUDA_PATHFINDER_VER}" ]]; then |
| 22 | + export SPHINX_CUDA_PATHFINDER_VER=$(python -c "from importlib.metadata import version; \ |
| 23 | + ver = '.'.join(str(version('cuda-pathfinder')).split('.')[:3]); \ |
| 24 | + print(ver)" \ |
| 25 | + | awk -F'+' '{print $1}') |
| 26 | +fi |
| 27 | + |
| 28 | +# build the docs (in parallel) |
| 29 | +SPHINXOPTS="-j 4 -d build/.doctrees" make html |
| 30 | + |
| 31 | +# for debugging/developing (conf.py), please comment out the above line and |
| 32 | +# use the line below instead, as we must build in serial to avoid getting |
| 33 | +# obsecure Sphinx errors |
| 34 | +#SPHINXOPTS="-v" make html |
| 35 | + |
| 36 | +# to support version dropdown menu |
| 37 | +cp ./versions.json build/html |
| 38 | + |
| 39 | +# to have a redirection page (to the latest docs) |
| 40 | +cp source/_templates/main.html build/html/index.html |
| 41 | + |
| 42 | +# ensure that the latest docs is the one we built |
| 43 | +if [[ $LATEST_ONLY == "0" ]]; then |
| 44 | + cp -r build/html/${SPHINX_CUDA_PATHFINDER_VER} build/html/latest |
| 45 | +else |
| 46 | + mv build/html/${SPHINX_CUDA_PATHFINDER_VER} build/html/latest |
| 47 | +fi |
| 48 | + |
| 49 | +# ensure that the Sphinx reference uses the latest docs |
| 50 | +cp build/html/latest/objects.inv build/html |
0 commit comments