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