Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion cuda_python/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,27 @@ def _html_baseurl():
# - https://stackoverflow.com/a/61694897/2344149
# - https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_epilog
CUDA_PYTHON_DOMAIN = os.environ.get("CUDA_PYTHON_DOMAIN", "https://nvidia.github.io/cuda-python")
_build_release_docs = os.environ.get("IS_RELEASE") == "true"
_bindings_docs_path = f"{release}/" if _build_release_docs else "latest"
_bindings_docs_url = f"{CUDA_PYTHON_DOMAIN}/cuda-bindings/{_bindings_docs_path}"

rst_epilog = f"""
.. _cuda.core: {CUDA_PYTHON_DOMAIN}/cuda-core/latest
.. _cuda.bindings: {CUDA_PYTHON_DOMAIN}/cuda-bindings/latest
.. _cuda.bindings: {_bindings_docs_url}
.. _cuda.pathfinder: {CUDA_PYTHON_DOMAIN}/cuda-pathfinder/latest
"""


def _pin_bindings_toctree(_app, docname, source):
if docname != "index":
return

entry = " cuda.bindings <https://nvidia.github.io/cuda-python/cuda-bindings/latest>"
if entry not in source[0]:
raise ValueError("Expected the cuda.bindings toctree entry in index.rst")
source[0] = source[0].replace(entry, f" cuda.bindings <{_bindings_docs_url}>", 1)


def setup(app):
if _build_release_docs:
app.connect("source-read", _pin_bindings_toctree)
4 changes: 2 additions & 2 deletions cuda_python/docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ All of the previously available functionality from the ``cuda-python`` package w
be available, please refer to the `cuda.bindings`_ documentation for installation guide and further detail.

..
The urls above can be auto-inserted by Sphinx (see rst_epilog in conf.py), but
not for the urls below, which must be hard-coded due to Sphinx limitation...
In release builds, conf.py replaces the cuda.bindings toctree URL below
with the matching versioned URL used by the inline link.

.. toctree::
:maxdepth: 2
Expand Down
Loading