Skip to content

Commit 3b9276f

Browse files
fix: show the next version on the docs changelog
1 parent e0bfe3d commit 3b9276f

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

docs/conf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import sys
2222
from typing import Any, Optional
2323

24+
import versioningit
2425
from sphinx.application import Sphinx
2526

2627
# If extensions (or modules to document with autodoc) are in another directory,
@@ -109,9 +110,16 @@
109110
#
110111
# The full version, including alpha/beta/rc tags.
111112
release = importlib.metadata.version("disnake")
112-
113113
# The short X.Y version.
114114
version = ".".join(release.split(".")[:2])
115+
# The release for the next release
116+
next_release = versioningit.get_next_version(os.path.abspath(".."))
117+
next_version = ".".join((next_release).split(".", 2)[:2])
118+
119+
rst_prolog += f"""
120+
.. |vnext_full| replace:: {next_release}
121+
.. |vnext| replace:: {next_version}
122+
"""
115123

116124
_IS_READTHEDOCS = bool(os.getenv("READTHEDOCS"))
117125

docs/extensions/versionchange.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def run(self):
1818
# If the argument is |vnext|, replace with config version
1919
if self.arguments and self.arguments[0] == "|vnext|":
2020
# Get the version from the Sphinx config
21-
version = self.env.config.version
22-
self.arguments[0] = version
21+
self.arguments[0] = self.env.config.next_version
2322
return super().run()
2423

2524

@@ -28,6 +27,8 @@ def setup(app: Sphinx) -> SphinxExtensionMeta:
2827
app.add_directive("versionchanged", VersionAddedNext, override=True)
2928
app.add_directive("deprecated", VersionAddedNext, override=True)
3029

30+
app.add_config_value("next_version", None, "env", types=[str])
31+
3132
return {
3233
"parallel_read_safe": True,
3334
"parallel_write_safe": True,

docs/whats_new.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Changelog
1313
This page keeps a detailed human friendly rendering of what's new and changed
1414
in specific versions. Please see :ref:`version_guarantees` for more information.
1515

16-
.. towncrier-draft-entries:: |release| [UNRELEASED]
16+
.. towncrier-draft-entries:: |vnext_full| [UNRELEASED]
1717

1818
.. towncrier release notes start
1919

0 commit comments

Comments
 (0)