Skip to content

Commit d98b394

Browse files
authored
🩹Fix JSON-links on RTD (#728)
1 parent a52fc2a commit d98b394

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

‎.readthedocs.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ build:
1414
# nodejs: "16"
1515
# rust: "1.55"
1616
# golang: "1.17"
17+
jobs:
18+
pre_build:
19+
- python -m pip install -e .
20+
- python -c "import bo4e; print(bo4e.__gh_version__)"
21+
# This ensures that before trying to build the documentation, the package will have information about the
22+
# version tag. This is necessary for the documentation to build the links correctly.
1723

1824
# Build documentation in the docs/ directory with Sphinx
1925
sphinx:

‎docs/conf.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,16 @@
177177
# The name for this set of Sphinx documents. If None, it defaults to
178178
# "<project> v<release> documentation".
179179
try:
180-
from bo4e import __version__ as version
180+
from bo4e import __gh_version__ as version
181+
182+
print(f"Got version {version} from __gh_version__")
181183
except ImportError:
182184
pass
183185
else:
184186
release = version
185187

188+
print(f"Using version {release} for documentation")
189+
186190
# A shorter title for the navigation bar. Default is the same as html_title.
187191
# html_short_title = None
188192

‎src/bo4e/version.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
# Please keep this name in sync with the name of the project in pyproject.toml
1313
# This name is the name of the package on pypi.org
1414
if re.match(r"^(\d+\.\d+\.\d+)(rc\d+)?$", __version__):
15-
__gh_version__ = re.sub(r"^(\d+\.\d+\.\d+)(rc\d+)?$", r"v\1-\2", __version__)
15+
16+
def _repl(match: re.Match[str]) -> str:
17+
if match.group(2) is not None:
18+
return f"v{match.group(1)}-{match.group(2)}"
19+
return f"v{match.group(1)}"
20+
21+
__gh_version__ = re.sub(r"^(\d+\.\d+\.\d+)(rc\d+)?$", _repl, __version__)
1622
else:
1723
__gh_version__ = f"v{__version__}"

0 commit comments

Comments
 (0)