Skip to content

Commit 4acf825

Browse files
hugovkserhiy-storchakaAlexWaygood
authored
gh-101100: Fix Sphinx warnings in library/cmd.rst (#113502)
Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
1 parent fb02b66 commit 4acf825

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

Doc/library/cmd.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,30 @@ A :class:`Cmd` instance has the following methods:
7676
single: ! (exclamation); in a command interpreter
7777

7878
An interpreter instance will recognize a command name ``foo`` if and only if it
79-
has a method :meth:`do_foo`. As a special case, a line beginning with the
79+
has a method :meth:`!do_foo`. As a special case, a line beginning with the
8080
character ``'?'`` is dispatched to the method :meth:`do_help`. As another
8181
special case, a line beginning with the character ``'!'`` is dispatched to the
82-
method :meth:`do_shell` (if such a method is defined).
82+
method :meth:`!do_shell` (if such a method is defined).
8383

8484
This method will return when the :meth:`postcmd` method returns a true value.
8585
The *stop* argument to :meth:`postcmd` is the return value from the command's
8686
corresponding :meth:`!do_\*` method.
8787

8888
If completion is enabled, completing commands will be done automatically, and
89-
completing of commands args is done by calling :meth:`complete_foo` with
89+
completing of commands args is done by calling :meth:`!complete_foo` with
9090
arguments *text*, *line*, *begidx*, and *endidx*. *text* is the string prefix
9191
we are attempting to match: all returned matches must begin with it. *line* is
9292
the current input line with leading whitespace removed, *begidx* and *endidx*
9393
are the beginning and ending indexes of the prefix text, which could be used to
9494
provide different completion depending upon which position the argument is in.
9595

96-
All subclasses of :class:`Cmd` inherit a predefined :meth:`do_help`. This
96+
97+
.. method:: Cmd.do_help(arg)
98+
99+
All subclasses of :class:`Cmd` inherit a predefined :meth:`!do_help`. This
97100
method, called with an argument ``'bar'``, invokes the corresponding method
98-
:meth:`help_bar`, and if that is not present, prints the docstring of
99-
:meth:`do_bar`, if available. With no argument, :meth:`do_help` lists all
101+
:meth:`!help_bar`, and if that is not present, prints the docstring of
102+
:meth:`!do_bar`, if available. With no argument, :meth:`!do_help` lists all
100103
available help topics (that is, all commands with corresponding
101104
:meth:`!help_\*` methods or commands that have docstrings), and also lists any
102105
undocumented commands.
@@ -229,8 +232,8 @@ Instances of :class:`Cmd` subclasses have some public instance variables:
229232
.. attribute:: Cmd.use_rawinput
230233

231234
A flag, defaulting to true. If true, :meth:`cmdloop` uses :func:`input` to
232-
display a prompt and read the next command; if false, :meth:`sys.stdout.write`
233-
and :meth:`sys.stdin.readline` are used. (This means that by importing
235+
display a prompt and read the next command; if false, :data:`sys.stdout.write() <sys.stdout>`
236+
and :data:`sys.stdin.readline() <sys.stdin>` are used. (This means that by importing
234237
:mod:`readline`, on systems that support it, the interpreter will automatically
235238
support :program:`Emacs`\ -like line editing and command-history keystrokes.)
236239

@@ -249,14 +252,14 @@ This section presents a simple example of how to build a shell around a few of
249252
the commands in the :mod:`turtle` module.
250253

251254
Basic turtle commands such as :meth:`~turtle.forward` are added to a
252-
:class:`Cmd` subclass with method named :meth:`do_forward`. The argument is
255+
:class:`Cmd` subclass with method named :meth:`!do_forward`. The argument is
253256
converted to a number and dispatched to the turtle module. The docstring is
254257
used in the help utility provided by the shell.
255258

256259
The example also includes a basic record and playback facility implemented with
257260
the :meth:`~Cmd.precmd` method which is responsible for converting the input to
258-
lowercase and writing the commands to a file. The :meth:`do_playback` method
259-
reads the file and adds the recorded commands to the :attr:`cmdqueue` for
261+
lowercase and writing the commands to a file. The :meth:`!do_playback` method
262+
reads the file and adds the recorded commands to the :attr:`~Cmd.cmdqueue` for
260263
immediate playback::
261264

262265
import cmd, sys

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Doc/library/asyncio-policy.rst
3131
Doc/library/asyncio-subprocess.rst
3232
Doc/library/asyncio-task.rst
3333
Doc/library/bdb.rst
34-
Doc/library/cmd.rst
3534
Doc/library/collections.rst
3635
Doc/library/concurrent.futures.rst
3736
Doc/library/configparser.rst

0 commit comments

Comments
 (0)