Skip to content

Commit 1e577e1

Browse files
hugovkViicos
andauthored
[3.13] gh-105812: Make use of the Sphinx deco role in documentation (GH-139598) (#154983)
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
1 parent fc5a406 commit 1e577e1

37 files changed

Lines changed: 144 additions & 143 deletions

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types requ
10171017
special recursion handling. In addition to protecting the stack,
10181018
:c:member:`~PyTypeObject.tp_repr` also needs to track objects to prevent cycles. The
10191019
following two functions facilitate this functionality. Effectively,
1020-
these are the C equivalent to :func:`reprlib.recursive_repr`.
1020+
these are the C equivalent to :deco:`reprlib.recursive_repr`.
10211021
10221022
.. c:function:: int Py_ReprEnter(PyObject *object)
10231023

Doc/c-api/structures.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ method.
376376
377377
The method will be passed the type object as the first parameter rather
378378
than an instance of the type. This is used to create *class methods*,
379-
similar to what is created when using the :func:`classmethod` built-in
380-
function.
379+
similar to what is created when using the :deco:`classmethod` built-in
380+
decorator.
381381
382382
383383
.. c:macro:: METH_STATIC
@@ -386,7 +386,7 @@ method.
386386
387387
The method will be passed ``NULL`` as the first parameter rather than an
388388
instance of the type. This is used to create *static methods*, similar to
389-
what is created when using the :func:`staticmethod` built-in function.
389+
what is created when using the :deco:`staticmethod` built-in decorator.
390390
391391
One other constant controls whether a method is loaded in place of another
392392
definition with the same method name.

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Pending Removal in Python 3.15
8282
Use ``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``
8383
to create a TypedDict with zero field.
8484

85-
* The :func:`typing.no_type_check_decorator` decorator function
85+
* The :deco:`typing.no_type_check_decorator` decorator function
8686
has been deprecated since Python 3.13.
8787
After eight years in the :mod:`typing` module,
8888
it has yet to be supported by any major type checker.

Doc/faq/programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ How do I cache method calls?
20012001
----------------------------
20022002

20032003
The two principal tools for caching methods are
2004-
:func:`functools.cached_property` and :func:`functools.lru_cache`. The
2004+
:deco:`functools.cached_property` and :deco:`functools.lru_cache`. The
20052005
former stores results at the instance level and the latter at the class
20062006
level.
20072007

Doc/glossary.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ Glossary
382382
decorator
383383
A function returning another function, usually applied as a function
384384
transformation using the ``@wrapper`` syntax. Common examples for
385-
decorators are :func:`classmethod` and :func:`staticmethod`.
385+
decorators are :deco:`classmethod` and :deco:`staticmethod`.
386386

387387
The decorator syntax is merely syntactic sugar, the following two
388388
function definitions are semantically equivalent::
@@ -642,7 +642,7 @@ Glossary
642642
determined by the dispatch algorithm.
643643

644644
See also the :term:`single dispatch` glossary entry, the
645-
:func:`functools.singledispatch` decorator, and :pep:`443`.
645+
:deco:`functools.singledispatch` decorator, and :pep:`443`.
646646

647647
generic type
648648
A :term:`type` that can be parameterized; typically a

Doc/howto/annotations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ on an arbitrary object ``o``:
149149
as the ``globals``, and ``dict(vars(o))`` as the ``locals``,
150150
when calling :func:`eval`.
151151
* If ``o`` is a wrapped callable using :func:`functools.update_wrapper`,
152-
:func:`functools.wraps`, or :func:`functools.partial`, iteratively
152+
:deco:`functools.wraps`, or :func:`functools.partial`, iteratively
153153
unwrap it by accessing either ``o.__wrapped__`` or ``o.func`` as
154154
appropriate, until you have found the root unwrapped function.
155155
* If ``o`` is a callable (but not a class), use

Doc/howto/descriptor.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This guide has four major sections:
2828
4) The last section has pure Python equivalents for built-in descriptors that
2929
are written in C. Read this if you're curious about how functions turn
3030
into bound methods or about the implementation of common tools like
31-
:func:`classmethod`, :func:`staticmethod`, :func:`property`, and
31+
:deco:`classmethod`, :deco:`staticmethod`, :deco:`property`, and
3232
:term:`__slots__`.
3333

3434

@@ -317,8 +317,8 @@ Descriptors invert that relationship and allow the data being looked-up to
317317
have a say in the matter.
318318

319319
Descriptors are used throughout the language. It is how functions turn into
320-
bound methods. Common tools like :func:`classmethod`, :func:`staticmethod`,
321-
:func:`property`, and :func:`functools.cached_property` are all implemented as
320+
bound methods. Common tools like :deco:`classmethod`, :deco:`staticmethod`,
321+
:deco:`property`, and :deco:`functools.cached_property` are all implemented as
322322
descriptors.
323323

324324

@@ -1326,7 +1326,7 @@ example calls are unexciting:
13261326
30
13271327

13281328
Using the non-data descriptor protocol, a pure Python version of
1329-
:func:`staticmethod` would look like this:
1329+
:deco:`staticmethod` would look like this:
13301330

13311331
.. testcode::
13321332

@@ -1462,7 +1462,7 @@ Now a new dictionary of unique keys can be constructed like this:
14621462
{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}
14631463

14641464
Using the non-data descriptor protocol, a pure Python version of
1465-
:func:`classmethod` would look like this:
1465+
:deco:`classmethod` would look like this:
14661466

14671467
.. testcode::
14681468

@@ -1600,7 +1600,7 @@ matters when a large number of instances are going to be created.
16001600
4. Improves speed. Reading instance variables is 35% faster with
16011601
``__slots__`` (as measured with Python 3.10 on an Apple M1 processor).
16021602

1603-
5. Blocks tools like :func:`functools.cached_property` which require an
1603+
5. Blocks tools like :deco:`functools.cached_property` which require an
16041604
instance dictionary to function correctly:
16051605

16061606
.. testcode::

Doc/howto/enum.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Ensuring unique enumeration values
256256
----------------------------------
257257

258258
By default, enumerations allow multiple names as aliases for the same value.
259-
When this behavior isn't desired, you can use the :func:`unique` decorator::
259+
When this behavior isn't desired, you can use the :deco:`unique` decorator::
260260

261261
>>> from enum import Enum, unique
262262
>>> @unique
@@ -509,7 +509,7 @@ to use the standard :func:`repr`.
509509

510510
.. note::
511511

512-
Adding :func:`~dataclasses.dataclass` decorator to :class:`Enum`
512+
Adding :deco:`~dataclasses.dataclass` decorator to :class:`Enum`
513513
and its subclasses is not supported. It will not raise any errors,
514514
but it will produce very strange results at runtime, such as members
515515
being equal to each other::

Doc/howto/sorting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ Odds and Ends
308308
:meth:`~object.__lt__` is not implemented (see :func:`object.__lt__`
309309
for details on the mechanics). To avoid surprises, :pep:`8`
310310
recommends that all six comparison methods be implemented.
311-
The :func:`~functools.total_ordering` decorator is provided to make that
311+
The :deco:`~functools.total_ordering` decorator is provided to make that
312312
task easier.
313313

314314
* Key functions need not depend directly on the objects being sorted. A key

Doc/library/abc.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ The :mod:`!abc` module also provides the following decorator:
170170
or is derived from it. A class that has a metaclass derived from
171171
:class:`!ABCMeta` cannot be instantiated unless all of its abstract methods
172172
and properties are overridden. The abstract methods can be called using any
173-
of the normal 'super' call mechanisms. :func:`!abstractmethod` may be used
173+
of the normal 'super' call mechanisms. :deco:`!abstractmethod` may be used
174174
to declare abstract methods for properties and descriptors.
175175

176176
Dynamically adding abstract methods to a class, or attempting to modify the
177177
abstraction status of a method or class once it is created, are only
178178
supported using the :func:`update_abstractmethods` function. The
179-
:func:`!abstractmethod` only affects subclasses derived using regular
179+
:deco:`!abstractmethod` only affects subclasses derived using regular
180180
inheritance; "virtual subclasses" registered with the ABC's
181181
:meth:`~ABCMeta.register` method are not affected.
182182

183-
When :func:`!abstractmethod` is applied in combination with other method
183+
When :deco:`!abstractmethod` is applied in combination with other method
184184
descriptors, it should be applied as the innermost decorator, as shown in
185185
the following usage examples::
186186

@@ -218,7 +218,7 @@ The :mod:`!abc` module also provides the following decorator:
218218
the descriptor must identify itself as abstract using
219219
:attr:`!__isabstractmethod__`. In general, this attribute should be ``True``
220220
if any of the methods used to compose the descriptor are abstract. For
221-
example, Python's built-in :class:`property` does the equivalent of::
221+
example, Python's built-in :deco:`property` does the equivalent of::
222222

223223
class Descriptor:
224224
...
@@ -242,13 +242,13 @@ The :mod:`!abc` module also supports the following legacy decorators:
242242

243243
.. versionadded:: 3.2
244244
.. deprecated:: 3.3
245-
It is now possible to use :class:`classmethod` with
246-
:func:`abstractmethod`, making this decorator redundant.
245+
It is now possible to use :deco:`classmethod` with
246+
:deco:`abstractmethod`, making this decorator redundant.
247247

248-
A subclass of the built-in :func:`classmethod`, indicating an abstract
249-
classmethod. Otherwise it is similar to :func:`abstractmethod`.
248+
A subclass of the built-in :class:`classmethod`, indicating an abstract
249+
classmethod. Otherwise it is similar to :deco:`abstractmethod`.
250250

251-
This special case is deprecated, as the :func:`classmethod` decorator
251+
This special case is deprecated, as the :deco:`classmethod` decorator
252252
is now correctly identified as abstract when applied to an abstract
253253
method::
254254

@@ -263,13 +263,13 @@ The :mod:`!abc` module also supports the following legacy decorators:
263263

264264
.. versionadded:: 3.2
265265
.. deprecated:: 3.3
266-
It is now possible to use :class:`staticmethod` with
267-
:func:`abstractmethod`, making this decorator redundant.
266+
It is now possible to use :deco:`staticmethod` with
267+
:deco:`abstractmethod`, making this decorator redundant.
268268

269-
A subclass of the built-in :func:`staticmethod`, indicating an abstract
270-
staticmethod. Otherwise it is similar to :func:`abstractmethod`.
269+
A subclass of the built-in :class:`staticmethod`, indicating an abstract
270+
staticmethod. Otherwise it is similar to :deco:`abstractmethod`.
271271

272-
This special case is deprecated, as the :func:`staticmethod` decorator
272+
This special case is deprecated, as the :deco:`staticmethod` decorator
273273
is now correctly identified as abstract when applied to an abstract
274274
method::
275275

@@ -283,14 +283,14 @@ The :mod:`!abc` module also supports the following legacy decorators:
283283
.. decorator:: abstractproperty
284284

285285
.. deprecated:: 3.3
286-
It is now possible to use :class:`property`, :meth:`property.getter`,
287-
:meth:`property.setter` and :meth:`property.deleter` with
288-
:func:`abstractmethod`, making this decorator redundant.
286+
It is now possible to use :deco:`property`, :deco:`property.getter`,
287+
:deco:`property.setter` and :deco:`property.deleter` with
288+
:deco:`abstractmethod`, making this decorator redundant.
289289

290-
A subclass of the built-in :func:`property`, indicating an abstract
290+
A subclass of the built-in :class:`property`, indicating an abstract
291291
property.
292292

293-
This special case is deprecated, as the :func:`property` decorator
293+
This special case is deprecated, as the :deco:`property` decorator
294294
is now correctly identified as abstract when applied to an abstract
295295
method::
296296

0 commit comments

Comments
 (0)