Skip to content

Commit b3bfeae

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

39 files changed

Lines changed: 146 additions & 145 deletions

Doc/c-api/exceptions.rst

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

Doc/c-api/structures.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ method.
454454
455455
The method will be passed the type object as the first parameter rather
456456
than an instance of the type. This is used to create *class methods*,
457-
similar to what is created when using the :func:`classmethod` built-in
458-
function.
457+
similar to what is created when using the :deco:`classmethod` built-in
458+
decorator.
459459
460460
461461
.. c:macro:: METH_STATIC
@@ -464,7 +464,7 @@ method.
464464
465465
The method will be passed ``NULL`` as the first parameter rather than an
466466
instance of the type. This is used to create *static methods*, similar to
467-
what is created when using the :func:`staticmethod` built-in function.
467+
what is created when using the :deco:`staticmethod` built-in decorator.
468468
469469
One other constant controls whether a method is loaded in place of another
470470
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
@@ -2003,7 +2003,7 @@ How do I cache method calls?
20032003
----------------------------
20042004

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

Doc/glossary.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ Glossary
416416
decorator
417417
A function returning another function, usually applied as a function
418418
transformation using the ``@wrapper`` syntax. Common examples for
419-
decorators are :func:`classmethod` and :func:`staticmethod`.
419+
decorators are :deco:`classmethod` and :deco:`staticmethod`.
420420

421421
The decorator syntax is merely syntactic sugar, the following two
422422
function definitions are semantically equivalent::
@@ -689,7 +689,7 @@ Glossary
689689
determined by the dispatch algorithm.
690690

691691
See also the :term:`single dispatch` glossary entry, the
692-
:func:`functools.singledispatch` decorator, and :pep:`443`.
692+
:deco:`functools.singledispatch` decorator, and :pep:`443`.
693693

694694
generic type
695695
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
@@ -152,7 +152,7 @@ on an arbitrary object ``o``:
152152
as the ``globals``, and ``dict(vars(o))`` as the ``locals``,
153153
when calling :func:`eval`.
154154
* If ``o`` is a wrapped callable using :func:`functools.update_wrapper`,
155-
:func:`functools.wraps`, or :func:`functools.partial`, iteratively
155+
:deco:`functools.wraps`, or :func:`functools.partial`, iteratively
156156
unwrap it by accessing either ``o.__wrapped__`` or ``o.func`` as
157157
appropriate, until you have found the root unwrapped function.
158158
* 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
@@ -25,7 +25,7 @@ This guide has four major sections:
2525
4) The last section has pure Python equivalents for built-in descriptors that
2626
are written in C. Read this if you're curious about how functions turn
2727
into bound methods or about the implementation of common tools like
28-
:func:`classmethod`, :func:`staticmethod`, :func:`property`, and
28+
:deco:`classmethod`, :deco:`staticmethod`, :deco:`property`, and
2929
:term:`__slots__`.
3030

3131

@@ -314,8 +314,8 @@ Descriptors invert that relationship and allow the data being looked-up to
314314
have a say in the matter.
315315

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

321321

@@ -1323,7 +1323,7 @@ example calls are unexciting:
13231323
30
13241324

13251325
Using the non-data descriptor protocol, a pure Python version of
1326-
:func:`staticmethod` would look like this:
1326+
:deco:`staticmethod` would look like this:
13271327

13281328
.. testcode::
13291329

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

14651465
Using the non-data descriptor protocol, a pure Python version of
1466-
:func:`classmethod` would look like this:
1466+
:deco:`classmethod` would look like this:
14671467

14681468
.. testcode::
14691469

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

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

16071607
.. 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
@@ -372,7 +372,7 @@ Odds and Ends
372372
:meth:`~object.__lt__` is not implemented (see :func:`object.__lt__`
373373
for details on the mechanics). To avoid surprises, :pep:`8`
374374
recommends that all six comparison methods be implemented.
375-
The :func:`~functools.total_ordering` decorator is provided to make that
375+
The :deco:`~functools.total_ordering` decorator is provided to make that
376376
task easier.
377377

378378
* 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
@@ -166,17 +166,17 @@ The :mod:`!abc` module also provides the following decorator:
166166
or is derived from it. A class that has a metaclass derived from
167167
:class:`!ABCMeta` cannot be instantiated unless all of its abstract methods
168168
and properties are overridden. The abstract methods can be called using any
169-
of the normal 'super' call mechanisms. :func:`!abstractmethod` may be used
169+
of the normal 'super' call mechanisms. :deco:`!abstractmethod` may be used
170170
to declare abstract methods for properties and descriptors.
171171

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

179-
When :func:`!abstractmethod` is applied in combination with other method
179+
When :deco:`!abstractmethod` is applied in combination with other method
180180
descriptors, it should be applied as the innermost decorator, as shown in
181181
the following usage examples::
182182

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

219219
class Descriptor:
220220
...
@@ -238,13 +238,13 @@ The :mod:`!abc` module also supports the following legacy decorators:
238238

239239
.. versionadded:: 3.2
240240
.. deprecated:: 3.3
241-
It is now possible to use :class:`classmethod` with
242-
:func:`abstractmethod`, making this decorator redundant.
241+
It is now possible to use :deco:`classmethod` with
242+
:deco:`abstractmethod`, making this decorator redundant.
243243

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

247-
This special case is deprecated, as the :func:`classmethod` decorator
247+
This special case is deprecated, as the :deco:`classmethod` decorator
248248
is now correctly identified as abstract when applied to an abstract
249249
method::
250250

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

260260
.. versionadded:: 3.2
261261
.. deprecated:: 3.3
262-
It is now possible to use :class:`staticmethod` with
263-
:func:`abstractmethod`, making this decorator redundant.
262+
It is now possible to use :deco:`staticmethod` with
263+
:deco:`abstractmethod`, making this decorator redundant.
264264

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

268-
This special case is deprecated, as the :func:`staticmethod` decorator
268+
This special case is deprecated, as the :deco:`staticmethod` decorator
269269
is now correctly identified as abstract when applied to an abstract
270270
method::
271271

@@ -279,14 +279,14 @@ The :mod:`!abc` module also supports the following legacy decorators:
279279
.. decorator:: abstractproperty
280280

281281
.. deprecated:: 3.3
282-
It is now possible to use :class:`property`, :meth:`property.getter`,
283-
:meth:`property.setter` and :meth:`property.deleter` with
284-
:func:`abstractmethod`, making this decorator redundant.
282+
It is now possible to use :deco:`property`, :deco:`property.getter`,
283+
:deco:`property.setter` and :deco:`property.deleter` with
284+
:deco:`abstractmethod`, making this decorator redundant.
285285

286-
A subclass of the built-in :func:`property`, indicating an abstract
286+
A subclass of the built-in :class:`property`, indicating an abstract
287287
property.
288288

289-
This special case is deprecated, as the :func:`property` decorator
289+
This special case is deprecated, as the :deco:`property` decorator
290290
is now correctly identified as abstract when applied to an abstract
291291
method::
292292

0 commit comments

Comments
 (0)