Skip to content

Commit 252e2f7

Browse files
authored
gh-101100: Fix sphinx warnings in Doc/library/functools.rst (GH-136424)
Add index entries and anchors for cache_info, cache_clear and register.
1 parent 2c9a801 commit 252e2f7

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

@@ -418,7 +424,7 @@ The :mod:`functools` module defines the following functions:
418424
like normal functions, are handled as descriptors).
419425

420426
When *func* is a descriptor (such as a normal Python function,
421-
:func:`classmethod`, :func:`staticmethod`, :func:`abstractmethod` or
427+
:func:`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or
422428
another instance of :class:`partialmethod`), calls to ``__get__`` are
423429
delegated to the underlying descriptor, and an appropriate
424430
:ref:`partial object<partial-objects>` returned as the result.
@@ -499,7 +505,10 @@ The :mod:`functools` module defines the following functions:
499505
... print("Let me just say,", end=" ")
500506
... print(arg)
501507

502-
To add overloaded implementations to the function, use the :func:`register`
508+
.. method:: singledispatch.register()
509+
:no-typesetting:
510+
511+
To add overloaded implementations to the function, use the :func:`!register`
503512
attribute of the generic function, which can be used as a decorator. For
504513
functions annotated with types, the decorator will infer the type of the
505514
first argument automatically::
@@ -565,14 +574,14 @@ The :mod:`functools` module defines the following functions:
565574
runtime impact.
566575

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

570579
>>> def nothing(arg, verbose=False):
571580
... print("Nothing.")
572581
...
573582
>>> fun.register(type(None), nothing)
574583

575-
The :func:`register` attribute returns the undecorated function. This
584+
The :func:`~singledispatch.register` attribute returns the undecorated function. This
576585
enables decorator stacking, :mod:`pickling<pickle>`, and the creation
577586
of unit tests for each variant independently::
578587

@@ -650,10 +659,10 @@ The :mod:`functools` module defines the following functions:
650659
.. versionadded:: 3.4
651660

652661
.. versionchanged:: 3.7
653-
The :func:`register` attribute now supports using type annotations.
662+
The :func:`~singledispatch.register` attribute now supports using type annotations.
654663

655664
.. versionchanged:: 3.11
656-
The :func:`register` attribute now supports
665+
The :func:`~singledispatch.register` attribute now supports
657666
:class:`typing.Union` as a type annotation.
658667

659668

@@ -783,7 +792,7 @@ The :mod:`functools` module defines the following functions:
783792
'Docstring'
784793

785794
Without the use of this decorator factory, the name of the example function
786-
would have been ``'wrapper'``, and the docstring of the original :func:`example`
795+
would have been ``'wrapper'``, and the docstring of the original :func:`!example`
787796
would have been lost.
788797

789798

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Doc/extending/extending.rst
1515
Doc/library/ast.rst
1616
Doc/library/asyncio-extending.rst
1717
Doc/library/email.charset.rst
18-
Doc/library/functools.rst
1918
Doc/library/http.cookiejar.rst
2019
Doc/library/http.server.rst
2120
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