Derive the docs version instead of hardcoding it - #477
Merged
ThomasMBury merged 1 commit intoJul 30, 2026
Merged
Conversation
docs/source/conf.py had to be bumped by hand, so it drifted: it still read 2.1.1 while the package was on 2.1.3. It went unnoticed because only `version` was set, and the RTD theme renders `release` -- so the wrong value was never displayed anywhere a reader would see it. Resolve the version from installed package metadata first, since that is how the docs are actually built (.readthedocs.yaml installs the package, and so does CI), falling back to pyproject.toml for a tree where the package is not installed, and finally to a literal. The resolver cannot raise: fail_on_warning is set, so an exception here would take the whole build down. Set `release` as well as `version`, so the number is actually rendered. The page title changes from "ewstools documentation" to "ewstools 2.1.3 documentation".
Owner
|
thanks - looks good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Small follow-on to your docs pass this morning — different thing, so I split it out.
docs/source/conf.pyhadversion = "2.1.1"hardcoded. It has to be bumped by hand, so it drifted: it was already stale for 2.1.2 and stayed stale through 2.1.3.The reason nobody noticed is worth a sentence, because it's the actual bug. Only
versionwas set, andsphinx_rtd_themerendersrelease. So the wrong number existed but was never displayed anywhere a reader could see it — the page title read "ewstools documentation" with no version at all.This resolves the version instead:
.readthedocs.yamlpip-installs the package and so does CIpyproject.toml, for a tree where the package isn't installedand sets
releaseas well asversion, so it's actually rendered.The resolver cannot raise.
fail_on_warning: trueis set, so an exception inconf.pywould take the whole build down; every branch is wrapped and the last resort is the stringunknown.Verification
Built exactly as RTD does (
docs/requirements.txt+ the package,sphinx-build -W). Build clean, and the rendered title is now:Also checked the two fallbacks in isolation, since the first branch normally hides them: with the package absent it returns
2.1.3frompyproject.toml, and on an interpreter withouttomllib(3.10 and earlier) it returnsunknownrather than raising.One thing I did not change
.zenodo.jsonalso pins"version": "v2.1.1"and a hardcoded"publication_date": "2023-02-10". I was going to clean those up in the same PR, but I couldn't confirm from Zenodo's own documentation what happens when those fields are omitted — their docs saypublication_datedefaults to the current date, but say nothing aboutversionbeing taken from the release tag. Rather than guess in a metadata file, I've left it alone and mentioned it separately. It looks inert anyway: the Zenodo API only has the one 2023 record, so the GitHub integration doesn't appear to be firing.No rush on this one.