Skip to content

Commit 3c627af

Browse files
authored
Merge pull request #875 from python-cmd2/doc_streamline
Doc streamline
2 parents c7ac2e9 + 90152df commit 3c627af

19 files changed

+68
-87
lines changed

docs/api/cmd.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
cmd2.Cmd
22
========
33

4-
.. autoclass:: cmd2.cmd2.Cmd
4+
.. autoclass:: cmd2.Cmd
55
:members:
66

7+
.. automethod:: __init__
8+
79
.. attribute:: help_error
810

911
The error message displayed to the user when they request help for a

docs/api/decorators.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Decorators
22
==========
33

4-
.. autofunction:: cmd2.decorators.with_category
5-
6-
.. autofunction:: cmd2.decorators.with_argument_list
4+
.. autofunction:: cmd2.decorators.with_argparser
75

86
.. autofunction:: cmd2.decorators.with_argparser_and_unknown_args
97

10-
.. autofunction:: cmd2.decorators.with_argparser
8+
.. autofunction:: cmd2.decorators.with_argument_list
9+
10+
.. autofunction:: cmd2.decorators.with_category

docs/api/exceptions.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
Exceptions
22
==========
33

4-
.. autoexception:: cmd2.cmd2.EmbeddedConsoleExit
5-
6-
.. autoexception:: cmd2.cmd2.EmptyStatement
4+
.. autoexception:: cmd2.EmptyStatement

docs/doc_conventions.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,28 +167,20 @@ To reference a method or function, use one of the following approaches:
167167

168168
1. Reference the full dotted path of the method::
169169

170-
The :meth:`cmd2.cmd2.Cmd.poutput` method is similar to the Python built-in
170+
The :meth:`cmd2.Cmd.poutput` method is similar to the Python built-in
171171
print function.
172172

173-
Which renders as: The :meth:`cmd2.cmd2.Cmd.poutput` method is similar to the
173+
Which renders as: The :meth:`cmd2.Cmd.poutput` method is similar to the
174174
Python built-in print function.
175175

176176
2. Reference the full dotted path to the method, but only display the method
177177
name::
178178

179-
The :meth:`~cmd2.cmd2.Cmd.poutput` method is similar to the Python built-in print function.
179+
The :meth:`~cmd2.Cmd.poutput` method is similar to the Python built-in print function.
180180

181-
Which renders as: The :meth:`~cmd2.cmd2.Cmd.poutput` method is similar to the
181+
Which renders as: The :meth:`~cmd2.Cmd.poutput` method is similar to the
182182
Python built-in print function.
183183

184-
3. Reference a portion of the dotted path of the method::
185-
186-
The :meth:`.cmd2.Cmd.poutput` method is similar to the Python built-in print
187-
function.
188-
189-
Which renders as: The :meth:`.cmd2.Cmd.poutput` method is similar to the Python
190-
built-in print function.
191-
192184
Avoid either of these approaches:
193185

194186
1. Reference just the class name without enough dotted path::

docs/examples/alternate_event_loops.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Throughout this documentation we have focused on the **90%** use case, that is
55
the use case we believe around **90+%** of our user base is looking for. This
66
focuses on ease of use and the best out-of-the-box experience where developers
77
get the most functionality for the least amount of effort. We are talking
8-
about running cmd2 applications with the ``cmdloop()`` method::
8+
about running ``cmd2`` applications with the ``cmdloop()`` method::
99

1010
from cmd2 import Cmd
1111
class App(Cmd):
@@ -78,5 +78,5 @@ with several disadvantages, including:
7878

7979
Here is a little more info on ``runcmds_plus_hooks``:
8080

81-
.. automethod:: cmd2.cmd2.Cmd.runcmds_plus_hooks
81+
.. automethod:: cmd2.Cmd.runcmds_plus_hooks
8282
:noindex:

docs/features/argument_processing.rst

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,21 @@ applications.
3131
.. _argprint: https://github.com/python-cmd2/cmd2/blob/master/examples/arg_print.py
3232
.. _decorator: https://github.com/python-cmd2/cmd2/blob/master/examples/decorator_example.py
3333

34-
.. _decorators:
35-
36-
Decorators provided by cmd2 for argument processing
37-
---------------------------------------------------
38-
3934
``cmd2`` provides the following decorators for assisting with parsing arguments
4035
passed to commands:
4136

42-
.. automethod:: cmd2.decorators.with_argparser
43-
:noindex:
44-
.. automethod:: cmd2.decorators.with_argparser_and_unknown_args
45-
:noindex:
46-
.. automethod:: cmd2.decorators.with_argument_list
47-
:noindex:
37+
* :func:`cmd2.decorators.with_argparser`
38+
* :func:`cmd2.decorators.with_argparser_and_unknown_args`
39+
* :func:`cmd2.decorators.with_argument_list`
4840

4941
All of these decorators accept an optional **preserve_quotes** argument which
5042
defaults to ``False``. Setting this argument to ``True`` is useful for cases
5143
where you are passing the arguments to another command which might have its own
5244
argument parsing.
5345

5446

55-
Using the argument parser decorator
56-
-----------------------------------
47+
Argument Parsing
48+
----------------
5749

5850
For each command in the ``cmd2`` subclass which requires argument parsing,
5951
create a unique instance of ``argparse.ArgumentParser()`` which can parse the
@@ -108,8 +100,8 @@ Here's what it looks like::
108100
Help Messages
109101
-------------
110102

111-
By default, cmd2 uses the docstring of the command method when a user asks for
112-
help on the command. When you use the ``@with_argparser`` decorator, the
103+
By default, ``cmd2`` uses the docstring of the command method when a user asks
104+
for help on the command. When you use the ``@with_argparser`` decorator, the
113105
docstring for the ``do_*`` method is used to set the description for the
114106
``argparse.ArgumentParser``.
115107

@@ -215,8 +207,8 @@ Which yields:
215207
.. _argparse: https://docs.python.org/3/library/argparse.html
216208

217209

218-
Receiving an argument list
219-
--------------------------
210+
Argument List
211+
-------------
220212

221213
The default behavior of ``cmd2`` is to pass the user input directly to your
222214
``do_*`` methods as a string. The object passed to your method is actually a
@@ -265,7 +257,7 @@ argument list instead of a string::
265257
pass
266258

267259

268-
Unknown positional arguments
260+
Unknown Positional Arguments
269261
----------------------------
270262

271263
If you want all unknown arguments to be passed to your command as a list of
@@ -295,8 +287,8 @@ Here's what it looks like::
295287

296288
...
297289

298-
Using custom argparse.Namespace
299-
-------------------------------
290+
Using A Custom Namespace
291+
------------------------
300292

301293
In some cases, it may be necessary to write custom ``argparse`` code that is
302294
dependent on state data of your application. To support this ability while
@@ -332,7 +324,7 @@ Subcommands are supported for commands using either the ``@with_argparser`` or
332324
``@with_argparser_and_unknown_args`` decorator. The syntax for supporting them
333325
is based on argparse sub-parsers.
334326

335-
You may add multiple layers of subcommands for your command. Cmd2 will
327+
You may add multiple layers of subcommands for your command. ``cmd2`` will
336328
automatically traverse and tab-complete subcommands for all commands using
337329
argparse.
338330

docs/features/builtin_commands.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Builtin Commands
22
================
33

4-
Applications which subclass :class:`cmd2.cmd2.Cmd` inherit a number of commands
4+
Applications which subclass :class:`cmd2.Cmd` inherit a number of commands
55
which may be useful to your users. Developers can
66
:ref:`features/builtin_commands:Remove Builtin Commands` if they do not want
77
them to be part of the application.
@@ -130,9 +130,9 @@ This command lists available shortcuts. See
130130
Remove Builtin Commands
131131
-----------------------
132132

133-
Developers may not want to offer the commands builtin to :class:`cmd2.cmd2.Cmd`
133+
Developers may not want to offer the commands builtin to :class:`cmd2.Cmd`
134134
to users of their application. To remove a command you must delete the method
135-
implementing that command from the :class:`cmd2.cmd2.Cmd` object at runtime.
135+
implementing that command from the :class:`cmd2.Cmd` object at runtime.
136136
For example, if you wanted to remove the :ref:`features/builtin_commands:shell`
137137
command from your application::
138138

docs/features/completion.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ similar to the following to your class which inherits from ``cmd2.Cmd``::
3636
Tab Completion Using Argparse Decorators
3737
----------------------------------------
3838

39-
When using one the Argparse-based :ref:`decorators`, ``cmd2`` provides
40-
automatic tab-completion of flag names.
39+
When using one the Argparse-based :ref:`api/decorators:Decorators`, ``cmd2``
40+
provides automatic tab-completion of flag names.
4141

4242
Tab-completion of argument values can be configured by using one of five
4343
parameters to ``argparse.ArgumentParser.add_argument()``

docs/features/embedded_python_shells.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ The ``py`` command will run its arguments as a Python command. Entered without
55
arguments, it enters an interactive Python session. The session can call
66
"back" to your application through the name defined in ``self.pyscript_name``
77
(defaults to ``app``). This wrapper provides access to execute commands in
8-
your cmd2 application while maintaining isolation.
8+
your ``cmd2`` application while maintaining isolation.
99

1010
You may optionally enable full access to to your application by setting
1111
``self_in_py`` to ``True``. Enabling this flag adds ``self`` to the python
12-
session, which is a reference to your Cmd2 application. This can be useful for
13-
debugging your application.
12+
session, which is a reference to your ``cmd2`` application. This can be useful
13+
for debugging your application.
1414

1515
The ``app`` object (or your custom name) provides access to application
1616
commands through raw commands. For example, any application command call be

docs/features/generating_output.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,34 @@ methods::
77
print("Greetings, Professor Falken.", file=self.stdout)
88
self.stdout.write("Shall we play a game?\n")
99

10-
While you could send output directly to ``sys.stdout``, :mod:`cmd2.cmd2.Cmd`
10+
While you could send output directly to ``sys.stdout``, :mod:`cmd2.Cmd`
1111
can be initialized with a ``stdin`` and ``stdout`` variables, which it stores
1212
as ``self.stdin`` and ``self.stdout``. By using these variables every time you
1313
produce output, you can trivially change where all the output goes by changing
1414
how you initialize your class.
1515

16-
:mod:`cmd2.cmd2.Cmd` extends this approach in a number of convenient ways. See
16+
:mod:`cmd2.Cmd` extends this approach in a number of convenient ways. See
1717
:ref:`features/redirection:Output Redirection And Pipes` for information on how
1818
users can change where the output of a command is sent. In order for those
1919
features to work, the output you generate must be sent to ``self.stdout``. You
2020
can use the methods described above, and everything will work fine.
21-
:mod:`cmd2.cmd2.Cmd` also includes a number of output related methods which you
21+
:mod:`cmd2.Cmd` also includes a number of output related methods which you
2222
may use to enhance the output your application produces.
2323

2424

2525
Ordinary Output
2626
---------------
2727

28-
The :meth:`~.cmd2.Cmd.poutput` method is similar to the Python
29-
`built-in print function <https://docs.python.org/3/library/functions.html#print>`_. :meth:`~.cmd2.Cmd.poutput` adds two
28+
The :meth:`~cmd2.Cmd.poutput` method is similar to the Python
29+
`built-in print function <https://docs.python.org/3/library/functions.html#print>`_. :meth:`~cmd2.Cmd.poutput` adds two
3030
conveniences:
3131

3232
1. Since users can pipe output to a shell command, it catches
3333
``BrokenPipeError`` and outputs the contents of
3434
``self.broken_pipe_warning`` to ``stderr``. ``self.broken_pipe_warning``
3535
defaults to an empty string so this method will just swallow the exception.
3636
If you want to show an error message, put it in
37-
``self.broken_pipe_warning`` when you initialize :mod:`~cmd2.cmd2.Cmd`.
37+
``self.broken_pipe_warning`` when you initialize :mod:`~cmd2.Cmd`.
3838

3939
2. It examines and honors the :ref:`features/settings:allow_style` setting.
4040
See :ref:`features/generating_output:Colored Output` below for more details.

0 commit comments

Comments
 (0)