Skip to content

Commit 811972e

Browse files
[3.11] gh-101100: Fix Sphinx nitpicks in library/rlcompleter.rst (GH-113125) (#113159)
gh-101100: Fix Sphinx nitpicks in `library/rlcompleter.rst` (GH-113125) (cherry picked from commit 7bb00f0) Co-authored-by: Alex Waygood <[email protected]>
1 parent a056aab commit 811972e

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

Doc/library/readline.rst

+2
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ Startup hooks
213213
if Python was compiled for a version of the library that supports it.
214214

215215

216+
.. _readline-completion:
217+
216218
Completion
217219
----------
218220

Doc/library/rlcompleter.rst

+22-18
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
--------------
1212

13-
The :mod:`rlcompleter` module defines a completion function suitable for the
14-
:mod:`readline` module by completing valid Python identifiers and keywords.
13+
The :mod:`!rlcompleter` module defines a completion function suitable to be
14+
passed to :func:`~readline.set_completer` in the :mod:`readline` module.
1515

1616
When this module is imported on a Unix platform with the :mod:`readline` module
1717
available, an instance of the :class:`Completer` class is automatically created
18-
and its :meth:`complete` method is set as the :mod:`readline` completer.
18+
and its :meth:`~Completer.complete` method is set as the
19+
:ref:`readline completer <readline-completion>`. The method provides
20+
completion of valid Python :ref:`identifiers and keywords <identifiers>`.
1921

2022
Example::
2123

@@ -28,7 +30,7 @@ Example::
2830
readline.__name__ readline.parse_and_bind(
2931
>>> readline.
3032

31-
The :mod:`rlcompleter` module is designed for use with Python's
33+
The :mod:`!rlcompleter` module is designed for use with Python's
3234
:ref:`interactive mode <tut-interactive>`. Unless Python is run with the
3335
:option:`-S` option, the module is automatically imported and configured
3436
(see :ref:`rlcompleter-config`).
@@ -39,23 +41,25 @@ this module can still be used for custom purposes.
3941

4042
.. _completer-objects:
4143

42-
Completer Objects
43-
-----------------
44+
.. class:: Completer
4445

45-
Completer objects have the following method:
46+
Completer objects have the following method:
4647

48+
.. method:: Completer.complete(text, state)
4749

48-
.. method:: Completer.complete(text, state)
50+
Return the next possible completion for *text*.
4951

50-
Return the *state*\ th completion for *text*.
52+
When called by the :mod:`readline` module, this method is called
53+
successively with ``state == 0, 1, 2, ...`` until the method returns
54+
``None``.
5155

52-
If called for *text* that doesn't include a period character (``'.'``), it will
53-
complete from names currently defined in :mod:`__main__`, :mod:`builtins` and
54-
keywords (as defined by the :mod:`keyword` module).
55-
56-
If called for a dotted name, it will try to evaluate anything without obvious
57-
side-effects (functions will not be evaluated, but it can generate calls to
58-
:meth:`__getattr__`) up to the last part, and find matches for the rest via the
59-
:func:`dir` function. Any exception raised during the evaluation of the
60-
expression is caught, silenced and :const:`None` is returned.
56+
If called for *text* that doesn't include a period character (``'.'``), it will
57+
complete from names currently defined in :mod:`__main__`, :mod:`builtins` and
58+
keywords (as defined by the :mod:`keyword` module).
6159

60+
If called for a dotted name, it will try to evaluate anything without obvious
61+
side-effects (functions will not be evaluated, but it can generate calls to
62+
:meth:`~object.__getattr__`) up to the last part, and find matches for the
63+
rest via the :func:`dir` function. Any exception raised during the
64+
evaluation of the expression is caught, silenced and :const:`None` is
65+
returned.

Doc/tools/.nitignore

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ Doc/library/pyexpat.rst
8282
Doc/library/random.rst
8383
Doc/library/readline.rst
8484
Doc/library/resource.rst
85-
Doc/library/rlcompleter.rst
8685
Doc/library/select.rst
8786
Doc/library/signal.rst
8887
Doc/library/smtplib.rst

0 commit comments

Comments
 (0)