]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-101100: Fix Sphinx nitpicks in `library/reprlib.rst` (#112811) (#112815)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Wed, 6 Dec 2023 22:04:33 +0000 (22:04 +0000)
committerGitHub <noreply@github.com>
Wed, 6 Dec 2023 22:04:33 +0000 (22:04 +0000)
(cherry-picked from commit 3870d19d15)

Doc/library/reprlib.rst
Doc/tools/.nitignore

index 4b37c5ba60f4e62c8af00fc9b309d5e86868b0f2..e99db838dd8c3a48dec7535d78940cf69192dfe0 100644 (file)
@@ -10,7 +10,7 @@
 
 --------------
 
-The :mod:`reprlib` module provides a means for producing object representations
+The :mod:`!reprlib` module provides a means for producing object representations
 with limits on the size of the resulting strings. This is used in the Python
 debugger and may be useful in other contexts as well.
 
@@ -39,29 +39,31 @@ This module provides a class, an instance, and a function:
    limits on most sizes.
 
 In addition to size-limiting tools, the module also provides a decorator for
-detecting recursive calls to :meth:`__repr__` and substituting a placeholder
-string instead.
+detecting recursive calls to :meth:`~object.__repr__` and substituting a
+placeholder string instead.
 
 
 .. index:: single: ...; placeholder
 
 .. decorator:: recursive_repr(fillvalue="...")
 
-   Decorator for :meth:`__repr__` methods to detect recursive calls within the
+   Decorator for :meth:`~object.__repr__` methods to detect recursive calls within the
    same thread.  If a recursive call is made, the *fillvalue* is returned,
-   otherwise, the usual :meth:`__repr__` call is made.  For example:
-
-        >>> from reprlib import recursive_repr
-        >>> class MyList(list):
-        ...     @recursive_repr()
-        ...     def __repr__(self):
-        ...         return '<' + '|'.join(map(repr, self)) + '>'
-        ...
-        >>> m = MyList('abc')
-        >>> m.append(m)
-        >>> m.append('x')
-        >>> print(m)
-        <'a'|'b'|'c'|...|'x'>
+   otherwise, the usual :meth:`!__repr__` call is made.  For example:
+
+   .. doctest::
+
+      >>> from reprlib import recursive_repr
+      >>> class MyList(list):
+      ...     @recursive_repr()
+      ...     def __repr__(self):
+      ...         return '<' + '|'.join(map(repr, self)) + '>'
+      ...
+      >>> m = MyList('abc')
+      >>> m.append(m)
+      >>> m.append('x')
+      >>> print(m)
+      <'a'|'b'|'c'|...|'x'>
 
    .. versionadded:: 3.2
 
@@ -155,7 +157,9 @@ Subclassing Repr Objects
 The use of dynamic dispatching by :meth:`Repr.repr1` allows subclasses of
 :class:`Repr` to add support for additional built-in object types or to modify
 the handling of types already supported. This example shows how special support
-for file objects could be added::
+for file objects could be added:
+
+.. testcode::
 
    import reprlib
    import sys
@@ -169,3 +173,7 @@ for file objects could be added::
 
    aRepr = MyRepr()
    print(aRepr.repr(sys.stdin))         # prints '<stdin>'
+
+.. testoutput::
+
+   <stdin>
index 063372e93df16888731dae3637c0490298482b93..dd201152895c5f8be58d27abea50efeaab0a5110 100644 (file)
@@ -87,7 +87,6 @@ Doc/library/pydoc.rst
 Doc/library/pyexpat.rst
 Doc/library/random.rst
 Doc/library/readline.rst
-Doc/library/reprlib.rst
 Doc/library/resource.rst
 Doc/library/rlcompleter.rst
 Doc/library/select.rst