Skip to content

Commit deb33ec

Browse files
authored
gh-105812: Make use of the Sphinx deco role in documentation (#139598)
1 parent 6453065 commit deb33ec

40 files changed

Lines changed: 147 additions & 146 deletions

Doc/c-api/exceptions.rst

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

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
@@ -413,7 +413,7 @@ Glossary
413413
decorator
414414
A function returning another function, usually applied as a function
415415
transformation using the ``@wrapper`` syntax. Common examples for
416-
decorators are :func:`classmethod` and :func:`staticmethod`.
416+
decorators are :deco:`classmethod` and :deco:`staticmethod`.
417417

418418
The decorator syntax is merely syntactic sugar, the following two
419419
function definitions are semantically equivalent::
@@ -676,7 +676,7 @@ Glossary
676676
determined by the dispatch algorithm.
677677

678678
See also the :term:`single dispatch` glossary entry, the
679-
:func:`functools.singledispatch` decorator, and :pep:`443`.
679+
:deco:`functools.singledispatch` decorator, and :pep:`443`.
680680

681681
generic type
682682
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
@@ -154,7 +154,7 @@ on an arbitrary object ``o``:
154154
as the ``globals``, and ``dict(vars(o))`` as the ``locals``,
155155
when calling :func:`eval`.
156156
* If ``o`` is a wrapped callable using :func:`functools.update_wrapper`,
157-
:func:`functools.wraps`, or :func:`functools.partial`, iteratively
157+
:deco:`functools.wraps`, or :func:`functools.partial`, iteratively
158158
unwrap it by accessing either ``o.__wrapped__`` or ``o.func`` as
159159
appropriate, until you have found the root unwrapped function.
160160
* 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

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

14681468
Using the non-data descriptor protocol, a pure Python version of
1469-
:func:`classmethod` would look like this:
1469+
:deco:`classmethod` would look like this:
14701470

14711471
.. testcode::
14721472

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

1607-
5. Blocks tools like :func:`functools.cached_property` which require an
1607+
5. Blocks tools like :deco:`functools.cached_property` which require an
16081608
instance dictionary to function correctly:
16091609

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

381381
* 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-removed:: 3.3 3.21
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-removed:: 3.3 3.21
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-removed:: 3.3 3.21
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)