Skip to content

Commit 3064c16

Browse files
Define mainversion substitution as part of rst_prolog
1 parent 8ba784c commit 3064c16

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

conf.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,18 @@
167167
# sphinx-notfound-page
168168
notfound_urls_prefix = "/"
169169

170+
# Dynamically expose the Python version associated with the "main" branch.
171+
# The release cycle data may not be ordered, so choose the numerically highest
172+
# version key instead of relying on a specific entry's position.
173+
with open("include/release-cycle.json", encoding="UTF-8") as _f:
174+
_cycle = json.load(_f)
175+
_main_version = max(
176+
_cycle,
177+
key=lambda v: tuple(int(part) for part in v.split(".")),
178+
)
179+
170180
# prolog and epilogs
171-
rst_prolog = """
181+
rst_prolog = f"""
172182
.. |draft| replace::
173183
This is part of a **Draft** of the Python Contributor's Guide.
174184
Text in square brackets are notes about content to fill in.
@@ -185,18 +195,9 @@
185195
186196
.. _Refactoring the DevGuide: https://discuss.python.org/t/refactoring-the-devguide-into-a-contribution-guide/63409
187197
188-
"""
198+
.. |mainversion| replace:: {_main_version}
189199
190-
# Dynamically expose the Python version associated with the "main" branch.
191-
# The release cycle data may not be ordered, so choose the numerically highest
192-
# version key instead of relying on a specific entry's position.
193-
with open("include/release-cycle.json", encoding="UTF-8") as _f:
194-
_cycle = json.load(_f)
195-
_main_version = max(
196-
_cycle,
197-
key=lambda v: tuple(int(part) for part in v.split(".")),
198-
)
199-
rst_prolog += f"\n.. |mainversion| replace:: {_main_version}\n"
200+
"""
200201

201202
# sphinx.ext.extlinks
202203
# This config is a dictionary of external sites,

0 commit comments

Comments
 (0)