Skip to content

Commit 0790bcd

Browse files
LamentXU123serhiy-storchaka
authored andcommitted
[3.13] pythongh-101100: Fix sphinx warnings in Doc/library/functools.rst (pythonGH-136424)
Add index entries and anchors for cache_info, cache_clear and register. (cherry picked from commit 252e2f7) Co-authored-by: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
1 parent cba2974 commit 0790bcd

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

Doc/library/functools.rst

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,18 @@ The :mod:`functools` module defines the following functions:
199199
and *typed*. This is for information purposes only. Mutating the values
200200
has no effect.
201201

202+
.. method:: lru_cache.cache_info()
203+
:no-typesetting:
204+
202205
To help measure the effectiveness of the cache and tune the *maxsize*
203-
parameter, the wrapped function is instrumented with a :func:`cache_info`
206+
parameter, the wrapped function is instrumented with a :func:`!cache_info`
204207
function that returns a :term:`named tuple` showing *hits*, *misses*,
205208
*maxsize* and *currsize*.
206209

207-
The decorator also provides a :func:`cache_clear` function for clearing or
210+
.. method:: lru_cache.cache_clear()
211+
:no-typesetting:
212+
213+
The decorator also provides a :func:`!cache_clear` function for clearing or
208214
invalidating the cache.
209215

210216
The original underlying function is accessible through the
@@ -284,9 +290,9 @@ The :mod:`functools` module defines the following functions:
284290
class decorator supplies the rest. This simplifies the effort involved
285291
in specifying all of the possible rich comparison operations:
286292

287-
The class must define one of :meth:`__lt__`, :meth:`__le__`,
288-
:meth:`__gt__`, or :meth:`__ge__`.
289-
In addition, the class should supply an :meth:`__eq__` method.
293+
The class must define one of :meth:`~object.__lt__`, :meth:`~object.__le__`,
294+
:meth:`~object.__gt__`, or :meth:`~object.__ge__`.
295+
In addition, the class should supply an :meth:`~object.__eq__` method.
290296

291297
For example::
292298

@@ -369,7 +375,7 @@ The :mod:`functools` module defines the following functions:
369375
like normal functions, are handled as descriptors).
370376

371377
When *func* is a descriptor (such as a normal Python function,
372-
:func:`classmethod`, :func:`staticmethod`, :func:`abstractmethod` or
378+
:func:`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or
373379
another instance of :class:`partialmethod`), calls to ``__get__`` are
374380
delegated to the underlying descriptor, and an appropriate
375381
:ref:`partial object<partial-objects>` returned as the result.
@@ -447,7 +453,10 @@ The :mod:`functools` module defines the following functions:
447453
... print("Let me just say,", end=" ")
448454
... print(arg)
449455

450-
To add overloaded implementations to the function, use the :func:`register`
456+
.. method:: singledispatch.register()
457+
:no-typesetting:
458+
459+
To add overloaded implementations to the function, use the :func:`!register`
451460
attribute of the generic function, which can be used as a decorator. For
452461
functions annotated with types, the decorator will infer the type of the
453462
first argument automatically::
@@ -513,14 +522,14 @@ The :mod:`functools` module defines the following functions:
513522
runtime impact.
514523

515524
To enable registering :term:`lambdas<lambda>` and pre-existing functions,
516-
the :func:`register` attribute can also be used in a functional form::
525+
the :func:`~singledispatch.register` attribute can also be used in a functional form::
517526

518527
>>> def nothing(arg, verbose=False):
519528
... print("Nothing.")
520529
...
521530
>>> fun.register(type(None), nothing)
522531

523-
The :func:`register` attribute returns the undecorated function. This
532+
The :func:`~singledispatch.register` attribute returns the undecorated function. This
524533
enables decorator stacking, :mod:`pickling<pickle>`, and the creation
525534
of unit tests for each variant independently::
526535

@@ -598,10 +607,10 @@ The :mod:`functools` module defines the following functions:
598607
.. versionadded:: 3.4
599608

600609
.. versionchanged:: 3.7
601-
The :func:`register` attribute now supports using type annotations.
610+
The :func:`~singledispatch.register` attribute now supports using type annotations.
602611

603612
.. versionchanged:: 3.11
604-
The :func:`register` attribute now supports :data:`types.UnionType`
613+
The :func:`~singledispatch.register` attribute now supports :data:`types.UnionType`
605614
and :data:`typing.Union` as type annotations.
606615

607616

@@ -731,7 +740,7 @@ The :mod:`functools` module defines the following functions:
731740
'Docstring'
732741

733742
Without the use of this decorator factory, the name of the example function
734-
would have been ``'wrapper'``, and the docstring of the original :func:`example`
743+
would have been ``'wrapper'``, and the docstring of the original :func:`!example`
735744
would have been lost.
736745

737746

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Doc/library/ast.rst
1616
Doc/library/asyncio-extending.rst
1717
Doc/library/asyncio-policy.rst
1818
Doc/library/email.charset.rst
19-
Doc/library/functools.rst
2019
Doc/library/http.cookiejar.rst
2120
Doc/library/http.server.rst
2221
Doc/library/importlib.rst

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy