Skip to content

Commit 6032995

Browse files
authored
Fix grammar and spelling issues in documentation and some outdated info (#1509)
* Fix grammar and spelling issues in documentation and some outdated info * Address PR comments * Recreated screenshot used in the top-level README due to a bug that has been fixed.
1 parent 37b1b7d commit 6032995

37 files changed

+171
-168
lines changed

cmd2.png

34.5 KB
Loading

docs/doc_conventions.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ described by [Write The Docs](http://www.writethedocs.org)
77

88
In addition:
99

10-
- We have gone to great lengths to retain compatibility with the standard library cmd, the
11-
documentation should make it easy for developers to understand how to move from cmd to cmd2, and
12-
what benefits that will provide
10+
- We have gone to great lengths to retain compatibility with the standard library `cmd`, the
11+
documentation should make it easy for developers to understand how to move from `cmd` to `cmd2`,
12+
and what benefits that will provide
1313
- We should provide both descriptive and reference documentation.
1414
- API reference documentation should be generated from docstrings in the code
1515
- Documentation should include rich hyperlinking to other areas of the documentation, and to the API
@@ -18,7 +18,7 @@ In addition:
1818
## Style Checker
1919

2020
We strongly encourage all developers to use [Prettier](https://prettier.io/) for formatting all
21-
**Markdown** and YAML files. The easiest way to do this is to integrated it with your IDE and
21+
**Markdown** and YAML files. The easiest way to do this is to integrate it with your IDE and
2222
configure your IDE to format on save. You can also install `prettier` either using `npm` or OS
2323
package manager such as `brew` or `apt`.
2424

@@ -28,7 +28,7 @@ All source files in the documentation must:
2828

2929
- have all lower case file names
3030
- if the name has multiple words, separate them with an underscore
31-
- end in '.rst'
31+
- end in '.md'
3232

3333
## Indenting
3434

@@ -42,15 +42,15 @@ html.
4242

4343
## Titles and Headings
4444

45-
Reference the [Markdown Basic Syntax](https://www.markdownguide.org/basic-syntax/) for synatx basics
45+
Reference the [Markdown Basic Syntax](https://www.markdownguide.org/basic-syntax/) for syntax basics
4646
or [The Markdown Guide](https://www.markdownguide.org/) for a more complete reference.
4747

4848
## Inline Code
4949

5050
Code blocks can be created in two ways:
5151

5252
- Indent the block - this will show as a monospace code block, but won't include highighting
53-
- use the triple backticks followed by the code language, e.e. `python` and close with triple
53+
- use the triple backticks followed by the code language, e.g. `python` and close with triple
5454
backticks
5555

5656
If you want to show non-Python code, like shell commands, then use a different language such as
@@ -65,7 +65,7 @@ See the [Links](https://www.markdownguide.org/basic-syntax/) Markdown syntax doc
6565
The API documentation is mostly pulled from docstrings in the source code using the MkDocs
6666
[mkdocstrings](https://mkdocstrings.github.io/) plugin.
6767

68-
When using `mkdocstinrgs`, it must be preceded by a blank line before and after, i.e.:
68+
When using `mkdocstrings`, it must be preceded by a blank line before and after, i.e.:
6969

7070
```markdown
7171
::: cmd2.history.History

docs/examples/alternate_event_loops.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ However, there are some limitations to this way of using `cmd2`, mainly that `cm
1717
loop of a program. This can be unnecessarily restrictive and can prevent using libraries which
1818
depend on controlling their own event loop.
1919

20-
Many Python concurrency libraries involve or require an event loop which they are in control of such
21-
as [asyncio](https://docs.python.org/3/library/asyncio.html), [gevent](http://www.gevent.org/),
20+
Many Python concurrency libraries involve or require an event loop which they are in control of,
21+
such as [asyncio](https://docs.python.org/3/library/asyncio.html), [gevent](http://www.gevent.org/),
2222
[Twisted](https://twistedmatrix.com), etc.
2323

2424
`cmd2` applications can be executed in a fashion where `cmd2` doesn't own the main loop for the
@@ -44,7 +44,8 @@ if __name__ == '__main__':
4444
app.postloop()
4545
```
4646

47-
The `cmd2.Cmd.runcmds_plus_hooks()` method runs multiple commands via `cmd2.Cmd.onecmd_plus_hooks`.
47+
The `cmd2.Cmd.runcmds_plus_hooks()` method runs multiple commands via
48+
`cmd2.Cmd.onecmd_plus_hooks()`.
4849

4950
The `cmd2.Cmd.onecmd_plus_hooks()` method will do the following to execute a single command in a
5051
normal fashion:

docs/examples/getting_started.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ $ python getting_started.py
8181
(Cmd) set
8282
```
8383

84-
you will see our `maxrepeats` setting show up with it's default value of `3`.
84+
you will see our `maxrepeats` setting show up with its default value of `3`.
8585

8686
## Create A Command
8787

8888
Now we will create our first command, called `speak` which will echo back whatever we tell it to
8989
say. We are going to use an [argument processor](../features/argument_processing.md) so the `speak`
90-
command can shout and talk piglatin. We will also use some built in methods for
90+
command can shout and talk pig latin. We will also use some built in methods for
9191
[generating output](../features/generating_output.md). Add this code to `getting_started.py`, so
92-
that the `speak_parser` attribute and the `do_speak()` method are part of the `CmdLineApp()` class:
92+
that the `speak_parser` attribute and the `do_speak()` method are part of the `FirstApp()` class:
9393

9494
```py
9595
speak_parser = cmd2.Cmd2ArgumentParser()
@@ -146,13 +146,13 @@ At the end of the method, we use our `maxrepeats` setting as an upper limit to t
146146
we will print the output.
147147

148148
The last thing you'll notice is that we used the `self.poutput()` method to display our output.
149-
`poutput()` is a method provided by `cmd2`, which I strongly recommend you use anytime you want to
149+
`poutput()` is a method provided by `cmd2`, which I strongly recommend you use any time you want to
150150
[generate output](../features/generating_output.md). It provides the following benefits:
151151

152152
1. Allows the user to redirect output to a text file or pipe it to a shell process
153-
1. Gracefully handles `BrokenPipeWarning` exceptions for redirected output
153+
1. Gracefully handles `BrokenPipeError` exceptions for redirected output
154154
1. Makes the output show up in a [transcript](../features/transcripts.md)
155-
1. Honors the setting to [strip embedded ansi sequences](../features/settings.md#allow_style)
155+
1. Honors the setting to [strip embedded ANSI sequences](../features/settings.md#allow_style)
156156
(typically used for background and foreground colors)
157157

158158
Go run the script again, and try out the `speak` command. Try typing `help speak`, and you will see
@@ -215,7 +215,7 @@ Some use cases benefit from the ability to have commands that span more than one
215215
you might want the ability for your user to type in a SQL command, which can often span lines and
216216
which are terminated with a semicolon. Let's add a
217217
[multiline command](../features/multiline_commands.md) to our application. First we'll create a new
218-
command called `orate`. This code shows both the definition of our `speak`command, and the`orate`
218+
command called `orate`. This code shows both the definition of our `speak` command, and the `orate`
219219
command:
220220

221221
```py
@@ -267,9 +267,9 @@ persist between invocations of your application, you'll need to do a little work
267267

268268
Users can access command history using two methods:
269269

270-
- the [readline](https://docs.python.org/3/library/readline.html) library which provides a python
270+
- The [readline](https://docs.python.org/3/library/readline.html) library which provides a Python
271271
interface to the [GNU readline library](https://en.wikipedia.org/wiki/GNU_Readline)
272-
- the `history` command which is built-in to `cmd2`
272+
- The `history` command which is built-in to `cmd2`
273273

274274
From the prompt in a `cmd2`-based application, you can press `Control-p` to move to the previously
275275
entered command, and `Control-n` to move to the next command. You can also search through the
@@ -280,10 +280,10 @@ details, including all the available commands, and instructions for customizing
280280
The `history` command allows a user to view the command history, and select commands from history by
281281
number, range, string search, or regular expression. With the selected commands, users can:
282282

283-
- re-run the commands
284-
- edit the selected commands in a text editor, and run them after the text editor exits
285-
- save the commands to a file
286-
- run the commands, saving both the commands and their output to a file
283+
- Re-run the commands
284+
- Edit the selected commands in a text editor, and run them after the text editor exits
285+
- Save the commands to a file
286+
- Run the commands, saving both the commands and their output to a file
287287

288288
Learn more about the `history` command by typing `history -h` at any `cmd2` input prompt, or by
289289
exploring [Command History For Users](../features/history.md#for-users).

docs/features/argument_processing.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ following for you:
99
1. Passes the resulting `argparse.Namespace` object to your command function. The `Namespace`
1010
includes the `Statement` object that was created when parsing the command line. It can be
1111
retrieved by calling `cmd2_statement.get()` on the `Namespace`.
12-
1. Adds the usage message from the argument parser to your command.
13-
1. Checks if the `-h/--help` option is present, and if so, display the help message for the command
12+
1. Adds the usage message from the argument parser to your command's help.
13+
1. Checks if the `-h/--help` option is present, and if so, displays the help message for the command
1414

15-
These features are all provided by the `@with_argparser` decorator which is importable from `cmd2`.
15+
These features are all provided by the `@with_argparser` decorator which is imported from `cmd2`.
1616

1717
See the
1818
[argparse_example](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_example.py)
@@ -49,7 +49,7 @@ argparser.add_argument('-r', '--repeat', type=int, help='output [n] times')
4949
argparser.add_argument('word', nargs='?', help='word to say')
5050

5151
@with_argparser(argparser)
52-
def do_speak(self, opts)
52+
def do_speak(self, opts):
5353
"""Repeats what you tell me to."""
5454
arg = opts.word
5555
if opts.piglatin:
@@ -91,7 +91,7 @@ the `help tag` command displays:
9191
```text
9292
usage: tag [-h] tag content [content ...]
9393
94-
create a html tag
94+
create an HTML tag
9595
9696
positional arguments:
9797
tag tag
@@ -101,13 +101,13 @@ optional arguments:
101101
-h, --help show this help message and exit
102102
```
103103

104-
If you would prefer you can set the `description` while instantiating the `argparse.ArgumentParser`
104+
If you would prefer, you can set the `description` while instantiating the `argparse.ArgumentParser`
105105
and leave the docstring on your method empty:
106106

107107
```py
108108
from cmd2 import Cmd2ArgumentParser, with_argparser
109109

110-
argparser = Cmd2ArgumentParser(description='create an html tag')
110+
argparser = Cmd2ArgumentParser(description='create an HTML tag')
111111
argparser.add_argument('tag', help='tag')
112112
argparser.add_argument('content', nargs='+', help='content to surround with tag')
113113
@with_argparser(argparser)
@@ -121,7 +121,7 @@ Now when the user enters `help tag` they see:
121121
```text
122122
usage: tag [-h] tag content [content ...]
123123
124-
create an html tag
124+
create an HTML tag
125125
126126
positional arguments:
127127
tag tag
@@ -136,7 +136,7 @@ To add additional text to the end of the generated help message, use the `epilog
136136
```py
137137
from cmd2 import Cmd2ArgumentParser, with_argparser
138138

139-
argparser = Cmd2ArgumentParser(description='create an html tag',
139+
argparser = Cmd2ArgumentParser(description='create an HTML tag',
140140
epilog='This command cannot generate tags with no content, like <br/>.')
141141
argparser.add_argument('tag', help='tag')
142142
argparser.add_argument('content', nargs='+', help='content to surround with tag')
@@ -151,7 +151,7 @@ Which yields:
151151
```text
152152
usage: tag [-h] tag content [content ...]
153153
154-
create an html tag
154+
create an HTML tag
155155
156156
positional arguments:
157157
tag tag
@@ -195,7 +195,7 @@ class CmdLineApp(cmd2.Cmd):
195195
self.poutput(arg)
196196
```
197197

198-
If you don't want to access the additional attributes on the string passed to you`do_*` method you
198+
If you don't want to access the additional attributes on the string passed to your `do_*` method you
199199
can still have `cmd2` apply shell parsing rules to the user input and pass you a list of arguments
200200
instead of a string. Apply the `@with_argument_list` decorator to those methods that should receive
201201
an argument list instead of a string:
@@ -320,7 +320,7 @@ def do_foo(self, args: argparse.Namespace) -> None:
320320
```
321321

322322
However, if you do NOT want the custom decorator runtime behavior to occur even in the case of an
323-
`argparse` error, then that decorator needs to go **before** the `arpgarse` one, e.g.:
323+
`argparse` error, then that decorator needs to go **before** the `argparse` one, e.g.:
324324

325325
```py
326326
@my_decorator
@@ -338,9 +338,9 @@ example demonstrates both above cases in a concrete fashion.
338338
`cmd2` argparse decorators add the following attributes to argparse Namespaces. To avoid naming
339339
collisions, do not use any of the names for your argparse arguments.
340340

341-
- `cmd2_statement` - `cmd2.Cmd2AttributeWrapper` object containing `cmd2.Statement` object that was
342-
created when parsing the command line.
341+
- `cmd2_statement` - `cmd2.Cmd2AttributeWrapper` object containing the `cmd2.Statement` object that
342+
was created when parsing the command line.
343343
- `cmd2_handler` - `cmd2.Cmd2AttributeWrapper` object containing a subcommand handler function or
344344
`None` if one was not set.
345-
- `__subcmd_handler__` - used by cmd2 to identify the handler for a subcommand created with
345+
- `__subcmd_handler__` - used by cmd2 to identify the handler for a subcommand created with the
346346
`@cmd2.as_subcommand_to` decorator.

docs/features/builtin_commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ editor vi Program used by 'edit'
8989
feedback_to_output False Include nonessentials in '|' and '>' results
9090
max_completion_items 50 Maximum number of CompletionItems to display during tab
9191
completion
92-
quiet False Don't print nonessential feedback
92+
quiet False Don't print non-essential feedback
9393
scripts_add_to_history True Scripts and pyscripts add commands to history
9494
timing False Report execution times
9595
```

docs/features/clipboard.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ clipboard by ending the command with a greater than symbol:
1212
mycommand args >
1313
```
1414

15-
Think of it as though you are redirecting output to an unnamed, ephemeral place, you know, like the
16-
clipboard. You can also append output to the current contents of the clipboard by ending the command
17-
with two greater than symbols:
15+
Think of it as redirecting the output to an unnamed, ephemeral place: the clipboard. You can also
16+
append output to the current contents of the clipboard by ending the command with two greater than
17+
symbols:
1818

1919
```text
2020
mycommand arg1 arg2 >>

docs/features/commands.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ if __name__ == '__main__':
2828
sys.exit(c.cmdloop())
2929
```
3030

31-
This application subclasses `cmd2.Cmd` but has no code of it's own, so all functionality (and
32-
there's quite a bit) is inherited. Lets create a simple command in this application called `echo`
33-
which outputs any arguments given to it. Add this method to the class:
31+
This application subclasses `cmd2.Cmd` but has no code of its own, so all functionality (and there's
32+
quite a bit) is inherited. Let's create a simple command in this application called `echo` which
33+
outputs any arguments given to it. Add this method to the class:
3434

3535
```py
3636
def do_echo(self, line):
@@ -55,7 +55,7 @@ A command is passed one argument: a string which contains all the rest of the us
5555
in `cmd2` this string is actually a `Statement` object, which is a subclass of `str` to retain
5656
backwards compatibility.
5757

58-
`cmd2` has a much more sophsticated parsing engine than what's included in the
58+
`cmd2` has a much more sophisticated parsing engine than what's included in the
5959
[cmd](https://docs.python.org/3/library/cmd.html) module. This parsing handles:
6060

6161
- quoted arguments
@@ -105,7 +105,7 @@ terminator
105105
this attribute will tell you which one the user typed.
106106

107107
For many simple commands, like the `echo` command above, you can ignore the `Statement` object and
108-
all of it's attributes and just use the passed value as a string. You might choose to use the `argv`
108+
all of its attributes and just use the passed value as a string. You might choose to use the `argv`
109109
attribute to do more sophisticated argument processing. Before you go too far down that path, you
110110
should check out the [Argument Processing](./argument_processing.md) functionality included with
111111
`cmd2`.
@@ -149,7 +149,7 @@ def do_bail(self, line):
149149
"""Exit the application"""
150150
self.perror("fatal error, exiting")
151151
self.exit_code = 2
152-
return true
152+
return True
153153

154154
if __name__ == '__main__':
155155
import sys
@@ -174,8 +174,8 @@ Raising `SystemExit(code)` or calling `sys.exit(code)` in a command or hook func
174174

175175
You may choose to catch and handle any exceptions which occur in a command method. If the command
176176
method raises an exception, `cmd2` will catch it and display it for you. The
177-
[debug setting](./settings.md#debug) controls how the exception is displayed. If `debug` is `false`,
178-
which is the default, `cmd2` will display the exception name and message. If `debug` is `true`,
177+
[debug setting](./settings.md#debug) controls how the exception is displayed. If `debug` is `False`,
178+
which is the default, `cmd2` will display the exception name and message. If `debug` is `True`,
179179
`cmd2` will display a traceback, and then display the exception name and message.
180180

181181
There are a few exceptions which commands can raise that do not print as described above:
@@ -186,7 +186,7 @@ There are a few exceptions which commands can raise that do not print as describ
186186
- `KeyboardInterrupt` - raised if running in a text script and `stop` isn't already True to stop the
187187
script
188188

189-
All other `BaseExceptions` are not caught by `cmd2` and will be raised
189+
All other `BaseExceptions` are not caught by `cmd2` and will be raised.
190190

191191
## Disabling or Hiding Commands
192192

docs/features/completion.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ instance, `ArgparseCompleter` sets it to False when displaying completion hints.
8585

8686
## Tab Completion Using argparse Decorators {: #argparse-based }
8787

88-
When using one the argparse-based [cmd2.decorators](../api/decorators.md), `cmd2` provides automatic
89-
tab completion of flag names.
88+
When using one of the argparse-based [cmd2.decorators](../api/decorators.md), `cmd2` provides
89+
automatic tab completion of flag names.
9090

9191
Tab completion of argument values can be configured by using one of three parameters to
9292
`argparse.ArgumentParser.add_argument`
@@ -95,25 +95,26 @@ Tab completion of argument values can be configured by using one of three parame
9595
- `choices_provider`
9696
- `completer`
9797

98-
See the [arg_decorators](https://github.com/python-cmd2/cmd2/blob/main/examples/arg_decorators.py)
98+
See the
99+
[argparse_example](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_example.py)
99100
example for a demonstration of how to use the `choices` parameter. See the
100101
[argparse_completion](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_completion.py)
101102
example for a demonstration of how to use the `choices_provider` parameter. See the
102-
[arg_decorators](https://github.com/python-cmd2/cmd2/blob/main/examples/arg_decorators.py) or
103+
[argparse_example](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_example.py) or
103104
[argparse_completion](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_completion.py)
104105
example for a demonstration of how to use the `completer` parameter.
105106

106107
When tab completing flags or argument values for a `cmd2` command using one of these decorators,
107108
`cmd2` keeps track of state so that once a flag has already previously been provided, it won't
108-
attempt to tab complete it again. When no completion results exists, a hint for the current argument
109+
attempt to tab complete it again. When no completion results exist, a hint for the current argument
109110
will be displayed to help the user.
110111

111112
## CompletionItem For Providing Extra Context
112113

113114
When tab completing things like a unique ID from a database, it can often be beneficial to provide
114115
the user with some extra context about the item being completed, such as a description. To
115-
facilitate this, `cmd2` defines the `cmd2.argparse_custom.CompletionItem` class which can be
116-
returned from any of the 3 completion parameters: `choices`, `choices_provider`, and `completer`.
116+
facilitate this, `cmd2` defines the `cmd2.CompletionItem` class which can be returned from any of
117+
the 3 completion parameters: `choices`, `choices_provider`, and `completer`.
117118

118119
See the
119120
[argparse_completion](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_completion.py)

0 commit comments

Comments
 (0)