Skip to content

Commit 7d24ea9

Browse files
encukouAA-Turnerhugovk
authored
gh-121277: Allow .. versionadded:: next in docs (GH-121278)
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.) Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 1ff1b89 commit 7d24ea9

File tree

9 files changed

+36
-14
lines changed

9 files changed

+36
-14
lines changed

Doc/c-api/long.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
570570
On failure, return -1 with an exception set. This function always succeeds
571571
if *obj* is a :c:type:`PyLongObject` or its subtype.
572572
573-
.. versionadded:: 3.14
573+
.. versionadded:: next
574574
575575
576576
.. c:function:: PyObject* PyLong_GetInfo(void)

Doc/c-api/unicode.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ PyUnicodeWriter
15341534
The :c:type:`PyUnicodeWriter` API can be used to create a Python :class:`str`
15351535
object.
15361536
1537-
.. versionadded:: 3.14
1537+
.. versionadded:: next
15381538
15391539
.. c:type:: PyUnicodeWriter
15401540

Doc/library/ast.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ effects on the compilation of a program:
24912491
differ in whitespace or similar details. Attributes include line numbers
24922492
and column offsets.
24932493

2494-
.. versionadded:: 3.14
2494+
.. versionadded:: next
24952495

24962496

24972497
.. _ast-cli:

Doc/library/ctypes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ These are the fundamental ctypes data types:
23032303
Represents the C :c:expr:`double complex` datatype, if available. The
23042304
constructor accepts an optional :class:`complex` initializer.
23052305

2306-
.. versionadded:: 3.14
2306+
.. versionadded:: next
23072307

23082308

23092309
.. class:: c_float_complex

Doc/library/dis.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ iterations of the loop.
959959
list of constants supported by this instruction. Used by the :keyword:`assert`
960960
statement to load :exc:`AssertionError`.
961961

962-
.. versionadded:: 3.14
962+
.. versionadded:: next
963963

964964

965965
.. opcode:: LOAD_BUILD_CLASS
@@ -1826,7 +1826,7 @@ iterations of the loop.
18261826
If ``type(STACK[-1]).__xxx__`` is not a method, leave
18271827
``STACK[-1].__xxx__; NULL`` on the stack.
18281828

1829-
.. versionadded:: 3.14
1829+
.. versionadded:: next
18301830

18311831

18321832
**Pseudo-instructions**

Doc/library/pathlib.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ Copying, moving and deleting
15631563
This argument has no effect when copying files on Windows (where
15641564
metadata is always preserved).
15651565

1566-
.. versionadded:: 3.14
1566+
.. versionadded:: next
15671567

15681568

15691569
.. method:: Path.copy_into(target_dir, *, follow_symlinks=True, \
@@ -1574,7 +1574,7 @@ Copying, moving and deleting
15741574
:meth:`Path.copy`. Returns a new :class:`!Path` instance pointing to the
15751575
copy.
15761576

1577-
.. versionadded:: 3.14
1577+
.. versionadded:: next
15781578

15791579

15801580
.. method:: Path.rename(target)

Doc/library/symtable.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ Examining Symbol Tables
255255

256256
Return ``True`` if the symbol is a type parameter.
257257

258-
.. versionadded:: 3.14
258+
.. versionadded:: next
259259

260260
.. method:: is_global()
261261

@@ -302,7 +302,7 @@ Examining Symbol Tables
302302
be free from the perspective of ``C.method``, thereby allowing
303303
the latter to return *1* at runtime and not *2*.
304304

305-
.. versionadded:: 3.14
305+
.. versionadded:: next
306306

307307
.. method:: is_assigned()
308308

@@ -312,13 +312,13 @@ Examining Symbol Tables
312312

313313
Return ``True`` if the symbol is a comprehension iteration variable.
314314

315-
.. versionadded:: 3.14
315+
.. versionadded:: next
316316

317317
.. method:: is_comp_cell()
318318

319319
Return ``True`` if the symbol is a cell in an inlined comprehension.
320320

321-
.. versionadded:: 3.14
321+
.. versionadded:: next
322322

323323
.. method:: is_namespace()
324324

Doc/tools/extensions/pyspecific.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,22 @@ def run(self):
259259
return PyMethod.run(self)
260260

261261

262-
# Support for documenting version of removal in deprecations
262+
# Support for documenting version of changes, additions, deprecations
263+
264+
def expand_version_arg(argument, release):
265+
"""Expand "next" to the current version"""
266+
if argument == 'next':
267+
return sphinx_gettext('{} (unreleased)').format(release)
268+
return argument
269+
270+
271+
class PyVersionChange(VersionChange):
272+
def run(self):
273+
# Replace the 'next' special token with the current development version
274+
self.arguments[0] = expand_version_arg(self.arguments[0],
275+
self.config.release)
276+
return super().run()
277+
263278

264279
class DeprecatedRemoved(VersionChange):
265280
required_arguments = 2
@@ -270,7 +285,8 @@ class DeprecatedRemoved(VersionChange):
270285
def run(self):
271286
# Replace the first two arguments (deprecated version and removed version)
272287
# with a single tuple of both versions.
273-
version_deprecated = self.arguments[0]
288+
version_deprecated = expand_version_arg(self.arguments[0],
289+
self.config.release)
274290
version_removed = self.arguments.pop(1)
275291
self.arguments[0] = version_deprecated, version_removed
276292

@@ -474,6 +490,10 @@ def setup(app):
474490
app.add_role('gh', gh_issue_role)
475491
app.add_directive('impl-detail', ImplementationDetail)
476492
app.add_directive('availability', Availability)
493+
app.add_directive('versionadded', PyVersionChange, override=True)
494+
app.add_directive('versionchanged', PyVersionChange, override=True)
495+
app.add_directive('versionremoved', PyVersionChange, override=True)
496+
app.add_directive('deprecated', PyVersionChange, override=True)
477497
app.add_directive('deprecated-removed', DeprecatedRemoved)
478498
app.add_builder(PydocTopicsBuilder)
479499
app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Writers of CPython's documentation can now use ``next`` as the version for
2+
the ``versionchanged``, ``versionadded``, ``deprecated`` directives.

0 commit comments

Comments
 (0)