Skip to content

Commit 9c986e2

Browse files
authored
Fix version display in title bar (#2568)
* Move version parsing / prettying into a nice_version function * Use it to set a NICE_VERSION variable * Set RELEASE and VERSION both to NICE_VERSION * Update logging to show both NICE_VERSION and raw VERSION in output
1 parent 297bce3 commit 9c986e2

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

Diff for: doc/conf.py

+22-10
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,27 @@
7070
# from arcade.version import VERSION
7171
# or read the docs build will fail.
7272
from version import VERSION # pyright: ignore [reportMissingImports]
73-
log.info(f" Got version {VERSION!r}")
73+
log.info(f" Got raw version {VERSION=!r}")
74+
75+
76+
def nice_version(version_string: str) -> str:
77+
"""Format raw VERSION by removing leading zeroes.
78+
79+
When importing VERSION, Python defaults to formatting it as
80+
3.00 as of February 2025.
81+
"""
82+
out = []
83+
for part in version_string.split('.'):
84+
try:
85+
out.append(str(int(part)))
86+
except ValueError as _:
87+
out.append(part)
88+
return '.'.join(out)
89+
90+
91+
NICE_VERSION = nice_version(VERSION)
92+
log.info(f" Got nice version {NICE_VERSION=!r}")
7493

75-
# Check whether the version ends in an all-digit string
76-
ARCADE_VERSION_PARTS = []
77-
for part in VERSION.split('.'):
78-
if part.isdigit():
79-
ARCADE_VERSION_PARTS.append(part)
80-
else:
81-
ARCADE_VERSION_PARTS.append(part)
8294

8395
print()
8496
GIT_REF = 'development'
@@ -233,9 +245,9 @@ def run_util(filename, run_name="__main__", init_globals=None):
233245
# built documents.
234246
#
235247
# The short X.Y version.
236-
version = VERSION
248+
version = NICE_VERSION
237249
# The full version, including alpha/beta/rc tags.
238-
release = RELEASE
250+
release = NICE_VERSION
239251

240252
# The language for content autogenerated by Sphinx. Refer to documentation
241253
# for a list of supported languages.

0 commit comments

Comments
 (0)