Skip to content

Commit a9d45ed

Browse files
docs: use importlib.metadata for version resolution (#1446)
Signed-off-by: Joshie <74162303+CoderJoshDK@users.noreply.github.com> Co-authored-by: Zenith <me@arielle.codes>
1 parent bc68dc8 commit a9d45ed

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

changelog/1446.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update version resolution in ``docs/conf.py`` to use :py:class:`importlib.metadata` instead of regex.

docs/conf.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15+
import importlib.metadata
1516
import importlib.util
1617
import inspect
1718
import os
@@ -106,15 +107,11 @@
106107
# |version| and |release|, also used in various other places throughout the
107108
# built documents.
108109
#
109-
# The short X.Y version.
110-
111-
version = ""
112-
with open("../disnake/__init__.py") as f:
113-
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) # pyright: ignore[reportOptionalMemberAccess]
114-
115110
# The full version, including alpha/beta/rc tags.
116-
release = version
111+
release = importlib.metadata.version("disnake")
117112

113+
# The short X.Y version.
114+
version = ".".join(release.split(".")[:2])
118115

119116
_IS_READTHEDOCS = bool(os.getenv("READTHEDOCS"))
120117

0 commit comments

Comments
 (0)