Skip to content

[doc-only] Fix shared Sphinx inventory links - #3624

Merged
rwgk merged 4 commits into
mainfrom
rwgk/fix-root-docs-inventory-urls
Nov 26, 2026
Merged

rwgk merged 4 commits into
mainfrom
rwgk/fix-root-docs-inventory-urls

Conversation

@rwgk

@rwgk rwgk commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

— codex on behalf of Ralf —

Description

The shared objects.inv files contain paths relative to latest/. Intersphinx consumers such as RMM and nvmath-python configure the component root as their base, so a target such as module/driver.html#cuda.bindings.driver.cuInit becomes a URL that returns 404.

Each docs builder calls copy_rebased_sphinx_inventory_one_level_up.py with build/html/latest/objects.inv. The helper writes build/html/objects.inv and prefixes relative targets with latest/ so either inventory base resolves to the same HTML. All five builders use it, including CUDA 12 and CUDA 13 bindings. The shared bindings docs on main come from the CUDA 13 builder. Release staging excludes the shared files under #3521.

The regular Pages deployment uses these eight shared inventory paths on gh-pages.

Doc set Root inventory latest/ inventory
cuda-python docs/objects.inv docs/latest/objects.inv
cuda-bindings docs/cuda-bindings/objects.inv docs/cuda-bindings/latest/objects.inv
cuda-core docs/cuda-core/objects.inv docs/cuda-core/latest/objects.inv
cuda-pathfinder docs/cuda-pathfinder/objects.inv docs/cuda-pathfinder/latest/objects.inv

The PR preview uses the same layout under docs/pr-preview/pr-3624/. Preview tree

Validation

  • Repository-wide pre-commit run --all-files and the inventory regression test passed. The test covers rebased relative targets, Sphinx anchor shorthand, object names and display text with spaces, and an absolute target.
  • Rehearsed all five standalone builders and the four-component aggregate in latest-only and versioned mode using their real Makefiles and published inventories as fixtures. Verified that CUDA 12 component and aggregate release staging retain their versioned inventories byte for byte.
  • Doc-only CI passed, including the CI tools tests and rendered-link check. CI run
  • Verified the deployment artifact’s digest and all eight inventory files. Sphinx resolved the root and latest/ inventory pairs to identical URLs and anchors for all four doc sets. 6,588 of 6,589 distinct targets resolved against the enclosed HTML. The sole miss was the pre-existing metapackage latest/py-modindex.html target. The bindings cuInit, Core Device, and Pathfinder load_nvidia_dynamic_lib links reached their expected anchors. Deployment artifact

Checklist

  • I have read the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the CI/CD CI/CD infrastructure label Nov 26, 2026
@rwgk rwgk added bug Something isn't working documentation Improvements or additions to documentation labels Nov 26, 2026
@rwgk rwgk self-assigned this Nov 26, 2026
@rwgk rwgk added this to the CI milestone Nov 26, 2026
@rwgk
rwgk marked this pull request as ready for review November 26, 2026 02:07
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Documentation
    • Documentation inventories now preserve relative links when made available from the parent directory. Absolute paths and URLs remain unchanged across the CUDA documentation builds.
  • Tests
    • Added coverage verifying that relative inventory links are adjusted while absolute URLs, inventory headers, and source files remain unchanged.

Adds a utility that copies Sphinx v2 inventories one level up and prefixes relative entry locations with the source directory name. Five documentation build scripts use the utility, and a test checks the output and confirms the source remains unchanged.

Changes: Documentation Inventory Build

Layer / File(s) Summary
Rebase inventory locations
cuda_python/docs/copy_rebased_sphinx_inventory_one_level_up.py, ci/tools/tests/test_rebase_sphinx_inventory.py
The utility preserves the inventory header, prefixes relative locations, and leaves absolute paths and URL targets unchanged. It validates the inventory header and destination. The test checks the rebased entries and confirms the source bytes are unchanged.
Use rebased inventories in documentation builds
cuda_bindings_12/docs/build_docs.sh, cuda_bindings_13/docs/build_docs.sh, cuda_core/docs/build_docs.sh, cuda_pathfinder/docs/build_docs.sh, cuda_python/docs/build_docs.sh
The five build scripts call the utility with the inventory in build/html/latest/objects.inv instead of copying it directly to build/html.

Possibly related issues

  • NVIDIA/cuda-python#3600 — The issue describes missing objects.inv files at staged component roots. This PR updates the documentation build scripts to create root inventories from the latest inventories, but the provided summary does not establish that it changes the release cleanup described in the issue.

Suggested reviewers: leofang, mdboom, copilot

Change: Bug fix

Merge Risk: Minimal · up to c01f1

This change rewrites the root Sphinx inventories so that Intersphinx consumers resolve links under latest/ instead of getting 404s. It affects only documentation builds. No merge-blocking risk was identified, and a revert is straightforward.

Security architecture risk: Minimal · up to c01f1

The change fixes relative links in shared documentation inventories without changing where they are published or allowing release builds to replace them. A failed rewrite stops the documentation build before deployment.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed behavior reaches consumers of the four shared root inventories. It changes relative link destinations within the corresponding documentation trees, not the scope of deployment authority.

Trust Boundaries and Controls

  • observed — Absolute paths and scheme-based targets pass through unchanged, as they did with the previous byte-for-byte copy. The helper does not fetch those destinations or serve as a URL allowlist.

Resilience and Maintainability Implications

  • inferred — The helper overwrites the root copy from the source, so rerunning it on the same input does not stack prefixes. A parse or write failure can leave the local build incomplete, but the fail-fast build and successful-build deployment gate keep that failure from publishing a partial inventory in the inspected workflow.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6efd1e2 and c01f1b6.

Files selected for processing: 7

  • ci/tools/tests/test_rebase_sphinx_inventory.py
  • cuda_bindings_12/docs/build_docs.sh
  • cuda_bindings_13/docs/build_docs.sh
  • cuda_core/docs/build_docs.sh
  • cuda_pathfinder/docs/build_docs.sh
  • cuda_python/docs/build_docs.sh
  • cuda_python/docs/copy_rebased_sphinx_inventory_one_level_up.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

@github-actions github-actions Bot added cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module cuda.pathfinder Everything related to the cuda.pathfinder module labels Nov 26, 2026
@rwgk rwgk changed the title Fix shared Sphinx inventory links [doc-only] Fix shared Sphinx inventory links Nov 26, 2026
@rwgk

rwgk commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c01f1b6

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor
Doc Preview CI
Preview removed because the pull request was closed or merged.

@rwgk
rwgk requested a review from rparolin November 26, 2026 05:01
@rwgk
rwgk enabled auto-merge (squash) November 26, 2026 05:01

header = b"\n".join(parts[:4]) + b"\n"
entries = zlib.decompress(parts[4]).decode()
rebased = _ENTRY.sub(rebase_entry, entries)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, not blocking: a line that does not fit _ENTRY is copied without the latest/ prefix and no error is raised. If the inventory format ever shifts, the 404s come back and the build stays green.

Counting the matches makes it fail loudly instead:

Suggested change
rebased = _ENTRY.sub(rebase_entry, entries)
rebased, matched = _ENTRY.subn(rebase_entry, entries)
expected = sum(1 for line in entries.split("\n") if line.strip())
if matched != expected:
raise ValueError(
f"{source}: {expected - matched} of {expected} inventory entries did not match the expected format"
)

Untested. A test that feeds in a junk line and expects ValueError would lock it in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #3640


import pytest

from cuda_python.docs.copy_rebased_sphinx_inventory_one_level_up import copy_rebased_inventory_one_level_up

@rparolin rparolin Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, not blocking: this import only resolves when the repo root is on sys.path, i.e. python -m pytest run from the top of the checkout. Bare pytest ci/tools/tests, or running from another directory, fails at collection with ModuleNotFoundError: cuda_python.

One way to fix it without touching the test: add this under [pytest] in the root pytest.ini.

pythonpath = .

Pytest then always puts the repo root on the import path, so the import here works as written. Note it applies to every test that uses the root config. Untested against the full suite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #3640

@rparolin rparolin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits, the pythonpath issue might be a little more than a nit but I'm not going to block the change over it. But it should probably be fixed.

@rwgk
rwgk merged commit 62d3257 into main Nov 26, 2026
44 checks passed
@rwgk
rwgk deleted the rwgk/fix-root-docs-inventory-urls branch November 26, 2026 19:46
github-actions Bot pushed a commit that referenced this pull request Nov 27, 2026
Removed preview folders for the following PRs:
- PR #3624
- PR #3625
@rwgk rwgk mentioned this pull request Nov 27, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CI/CD CI/CD infrastructure cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module cuda.pathfinder Everything related to the cuda.pathfinder module documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants