Skip to content

Commit 5aee727

Browse files
Copilotleofang
andcommitted
Create Sphinx documentation infrastructure for cuda.pathfinder
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
1 parent 6e6d961 commit 5aee727

20 files changed

Lines changed: 351 additions & 2 deletions

File tree

.github/workflows/build-docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
# - cuda-core
2020
# - cuda-bindings
2121
# - cuda-python
22+
# - cuda-pathfinder
2223
# - all
2324
git-tag:
2425
description: "Target git tag to build docs for"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CUDA Python is the home for accessing NVIDIA’s CUDA platform from Python. It c
44

55
* [cuda.core](https://nvidia.github.io/cuda-python/cuda-core/latest): Pythonic access to CUDA Runtime and other core functionalities
66
* [cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest): Low-level Python bindings to CUDA C APIs
7-
* [cuda.pathfinder](https://github.com/NVIDIA/cuda-python/blob/main/cuda_pathfinder/cuda/pathfinder/README.md): Utilities for locating CUDA components installed in the user's Python environment
7+
* [cuda.pathfinder](https://nvidia.github.io/cuda-python/cuda-pathfinder/latest): Utilities for locating CUDA components installed in the user's Python environment
88
* [cuda.cccl.cooperative](https://nvidia.github.io/cccl/python/cooperative): A Python module providing CCCL's reusable block-wide and warp-wide *device* primitives for use within Numba CUDA kernels
99
* [cuda.cccl.parallel](https://nvidia.github.io/cccl/python/parallel): A Python module for easy access to CCCL's highly efficient and customizable parallel algorithms, like `sort`, `scan`, `reduce`, `transform`, etc. that are callable on the *host*
1010
* [numba.cuda](https://nvidia.github.io/numba-cuda/): Numba's target for CUDA GPU programming by directly compiling a restricted subset of Python code into CUDA kernels and device functions following the CUDA execution model.

cuda_pathfinder/docs/Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+
# Minimal makefile for Sphinx documentation
5+
#
6+
7+
# You can set these variables from the command line, and also
8+
# from the environment for the first two.
9+
SPHINXOPTS ?= -j auto
10+
SPHINXBUILD ?= sphinx-build
11+
SOURCEDIR = source
12+
BUILDDIR = build/html/${SPHINX_CUDA_PATHFINDER_VER}
13+
14+
# Put it first so that "make" without argument is like "make help".
15+
help:
16+
@$(SPHINXBUILD) -b help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17+
18+
.PHONY: help Makefile
19+
20+
# Catch-all target: route all unknown targets to Sphinx using the new
21+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
22+
%: Makefile
23+
@$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

cuda_pathfinder/docs/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Build the documentation
2+
3+
1. Install the `cuda-bindings` package of the version that we need to document.
4+
2. Ensure the version is included in the [`versions.json`](./versions.json).
5+
3. Build the docs with `./build_docs.sh`.
6+
4. The html artifacts should be available under both `./build/html/latest` and `./build/html/<version>`.
7+
8+
Alternatively, we can build all the docs at once by running [`cuda_python/docs/build_all_docs.sh`](../../cuda_python/docs/build_all_docs.sh).
9+
10+
To publish the docs with the built version, it is important to note that the html files of older versions
11+
should be kept intact, in order for the version selection (through `versions.json`) to work.

cuda_pathfinder/docs/build_docs.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

cuda_pathfinder/docs/make.bat

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@ECHO OFF
2+
3+
REM SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4+
REM SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
5+
6+
pushd %~dp0
7+
8+
REM Command file for Sphinx documentation
9+
10+
if "%SPHINXBUILD%" == "" (
11+
set SPHINXBUILD=sphinx-build
12+
)
13+
set SOURCEDIR=source
14+
set BUILDDIR=build
15+
16+
if "%1" == "" goto help
17+
18+
%SPHINXBUILD% >NUL 2>NUL
19+
if errorlevel 9009 (
20+
echo.
21+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
22+
echo.installed, then set the SPHINXBUILD environment variable to point
23+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
24+
echo.may add the Sphinx directory to PATH.
25+
echo.
26+
echo.If you don't have Sphinx installed, grab it from
27+
echo.http://sphinx-doc.org/
28+
exit /b 1
29+
)
30+
31+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
32+
goto end
33+
34+
:help
35+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
36+
37+
:end
38+
popd
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"version": "latest",
4+
"url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/"
5+
},
6+
{
7+
"version": "1.1.0",
8+
"url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.1.0/"
9+
}
10+
]
332 KB
Loading
49.4 KB
Loading
47.7 KB
Loading

0 commit comments

Comments
 (0)