Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-121277: Allow .. versionadded:: next in docs #121278

Merged
merged 18 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
On failure, return -1 with an exception set. This function always succeeds
if *obj* is a :c:type:`PyLongObject` or its subtype.

.. versionadded:: 3.14
.. versionadded:: next


.. c:function:: PyObject* PyLong_GetInfo(void)
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ PyUnicodeWriter
The :c:type:`PyUnicodeWriter` API can be used to create a Python :class:`str`
object.

.. versionadded:: 3.14
.. versionadded:: next

.. c:type:: PyUnicodeWriter

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,7 @@ effects on the compilation of a program:
differ in whitespace or similar details. Attributes include line numbers
and column offsets.

.. versionadded:: 3.14
.. versionadded:: next


.. _ast-cli:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ These are the fundamental ctypes data types:
Represents the C :c:expr:`double complex` datatype, if available. The
constructor accepts an optional :class:`complex` initializer.

.. versionadded:: 3.14
.. versionadded:: next


.. class:: c_float_complex
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ iterations of the loop.
list of constants supported by this instruction. Used by the :keyword:`assert`
statement to load :exc:`AssertionError`.

.. versionadded:: 3.14
.. versionadded:: next


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

.. versionadded:: 3.14
.. versionadded:: next


**Pseudo-instructions**
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ Copying, moving and deleting
This argument has no effect when copying files on Windows (where
metadata is always preserved).

.. versionadded:: 3.14
.. versionadded:: next


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

.. versionadded:: 3.14
.. versionadded:: next


.. method:: Path.rename(target)
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/symtable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Examining Symbol Tables

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

.. versionadded:: 3.14
.. versionadded:: next

.. method:: is_global()

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

.. versionadded:: 3.14
.. versionadded:: next

.. method:: is_assigned()

Expand All @@ -312,13 +312,13 @@ Examining Symbol Tables

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

.. versionadded:: 3.14
.. versionadded:: next

.. method:: is_comp_cell()

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

.. versionadded:: 3.14
.. versionadded:: next

.. method:: is_namespace()

Expand Down
24 changes: 22 additions & 2 deletions Doc/tools/extensions/pyspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,22 @@ def 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):
required_arguments = 2
Expand All @@ -270,7 +285,8 @@ class DeprecatedRemoved(VersionChange):
def run(self):
# Replace the first two arguments (deprecated version and removed version)
# 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)
self.arguments[0] = version_deprecated, version_removed

Expand Down Expand Up @@ -474,6 +490,10 @@ def setup(app):
app.add_role('gh', gh_issue_role)
app.add_directive('impl-detail', ImplementationDetail)
app.add_directive('availability', Availability)
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_builder(PydocTopicsBuilder)
app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Writers of CPython's documentation can now use ``next`` as the version for
the ``versionchanged``, ``versionadded``, ``deprecated`` directives.
Loading