mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
[3.12] gh-121277: Allow .. versionadded:: next
in docs (GH-121278) (GH-125980)
Make `versionchanged:: next`` expand to current (unreleased) version. When a new CPython release is cut, the release manager will replace all such occurences of "next" with the just-released version. (See the issue for release-tools and devguide PRs.) (cherry picked from commit7d24ea9db3
) Also backports a minor fix-up: gh-121277: Raise nice error on `next` as second argument to deprecated-removed (GH-124623) (cherry-picked from commite349f73a5a
) Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
parent
05214e66b0
commit
1e01dcf429
2 changed files with 27 additions and 2 deletions
|
@ -184,7 +184,22 @@ class PyAbstractMethod(PyMethod):
|
||||||
return PyMethod.run(self)
|
return PyMethod.run(self)
|
||||||
|
|
||||||
|
|
||||||
# Support for documenting version of removal in deprecations
|
# Support for documenting version of changes, additions, deprecations
|
||||||
|
|
||||||
|
def expand_version_arg(argument, release):
|
||||||
|
"""Expand "next" to the current version"""
|
||||||
|
if argument == 'next':
|
||||||
|
return sphinx_gettext('{} (unreleased)').format(release)
|
||||||
|
return argument
|
||||||
|
|
||||||
|
|
||||||
|
class PyVersionChange(VersionChange):
|
||||||
|
def run(self):
|
||||||
|
# Replace the 'next' special token with the current development version
|
||||||
|
self.arguments[0] = expand_version_arg(self.arguments[0],
|
||||||
|
self.config.release)
|
||||||
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
class DeprecatedRemoved(VersionChange):
|
class DeprecatedRemoved(VersionChange):
|
||||||
required_arguments = 2
|
required_arguments = 2
|
||||||
|
@ -195,8 +210,12 @@ class DeprecatedRemoved(VersionChange):
|
||||||
def run(self):
|
def run(self):
|
||||||
# Replace the first two arguments (deprecated version and removed version)
|
# Replace the first two arguments (deprecated version and removed version)
|
||||||
# with a single tuple of both versions.
|
# with a single tuple of both versions.
|
||||||
version_deprecated = self.arguments[0]
|
version_deprecated = expand_version_arg(self.arguments[0],
|
||||||
|
self.config.release)
|
||||||
version_removed = self.arguments.pop(1)
|
version_removed = self.arguments.pop(1)
|
||||||
|
if version_removed == 'next':
|
||||||
|
raise ValueError(
|
||||||
|
'deprecated-removed:: second argument cannot be `next`')
|
||||||
self.arguments[0] = version_deprecated, version_removed
|
self.arguments[0] = version_deprecated, version_removed
|
||||||
|
|
||||||
# Set the label based on if we have reached the removal version
|
# Set the label based on if we have reached the removal version
|
||||||
|
@ -398,6 +417,10 @@ def setup(app):
|
||||||
app.add_role('issue', issue_role)
|
app.add_role('issue', issue_role)
|
||||||
app.add_role('gh', gh_issue_role)
|
app.add_role('gh', gh_issue_role)
|
||||||
app.add_directive('impl-detail', ImplementationDetail)
|
app.add_directive('impl-detail', ImplementationDetail)
|
||||||
|
app.add_directive('versionadded', PyVersionChange, override=True)
|
||||||
|
app.add_directive('versionchanged', PyVersionChange, override=True)
|
||||||
|
app.add_directive('versionremoved', PyVersionChange, override=True)
|
||||||
|
app.add_directive('deprecated', PyVersionChange, override=True)
|
||||||
app.add_directive('deprecated-removed', DeprecatedRemoved)
|
app.add_directive('deprecated-removed', DeprecatedRemoved)
|
||||||
app.add_builder(PydocTopicsBuilder)
|
app.add_builder(PydocTopicsBuilder)
|
||||||
app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature)
|
app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Writers of CPython's documentation can now use ``next`` as the version for
|
||||||
|
the ``versionchanged``, ``versionadded``, ``deprecated`` directives.
|
Loading…
Add table
Add a link
Reference in a new issue