Fix multi-version documentation to show correct version numbers #110
+170
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When building multi-version documentation with sphinx-multiversion for
branches v0.0.8-docs and v0.0.9-docs, both versions incorrectly displayed
"nvblox_torch 0.0.9" in the page titles and all wheel download URLs pointed
to v0.0.9 files, regardless of which version was being built.
Root Cause
Multiple interacting issues:
Python Module Caching: The original approach imported version from setup.py at module level. Python's import system cached the first imported module, causing all subsequent builds to reuse the same cached version (0.0.9) across all versions.
Timing Issues: conf.py is executed before sphinx-multiversion sets up version-specific source directories, so CWD-based detection failed.
Config Dictionary Creation: The nvblox_torch_docs_config dictionary was created at module import time with hardcoded/default version values, before the correct version could be detected.
Solution
Use Sphinx's setup() function which runs after initialization and provides
app.srcdir pointing to each version's checked-out source directory.
The setup() function:
Changes
docs/conf.py (both v0.0.8-docs and v0.0.9-docs):
docs/_templates/versioning.html (v0.0.8-docs):
docs/helpers.py (v0.0.9-docs):
Results
Each version now correctly displays:
v0.0.8-docs:
v0.0.9-docs:
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com