Skip to content

Commit c488540

Browse files
committed
First pass at removing outdated info from the documentation based on changes in the 3.0.0 release and adding info on new capabilities
1 parent 06796a4 commit c488540

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

docs/features/argument_processing.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ def do_speak(self, opts):
6161
self.poutput(arg)
6262
```
6363

64-
!!! note
65-
66-
`cmd2` sets the `prog` variable in the argument parser based on the name of the method it is decorating. This will override anything you specify in `prog` variable when creating the argument parser.
67-
6864
## Help Messages
6965

7066
By default, `cmd2` uses the docstring of the command method when a user asks for help on the

docs/features/generating_output.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ output you generate must be sent to `self.stdout`. You can use the methods descr
1919
everything will work fine. [cmd2.Cmd][] also includes a number of output related methods which you
2020
may use to enhance the output your application produces.
2121

22+
Since `cmd2` has a dependency on the [rich](https://github.com/Textualize/rich) library, all of
23+
`cmd2`'s output methods can natively render `rich`
24+
[renderable objects](https://rich.readthedocs.io/en/latest/protocol.html), enabling beautiful and
25+
complex output.
26+
2227
## Ordinary Output
2328

2429
The `cmd2.Cmd.poutput` method is similar to the Python
@@ -92,6 +97,16 @@ following sections:
9297
- [cmd2.string_utils][]
9398
- [cmd2.terminal_utils][]
9499

100+
The [color.py](https://github.com/python-cmd2/cmd2/blob/main/examples/color.py) example demonstrates
101+
all colors available to your `cmd2` application.
102+
103+
### Custom Themes
104+
105+
`cmd2` uses a `rich` `Theme` object to define styles for various UI elements. You can define your
106+
own custom theme using `cmd2.rich_utils.set_theme`. See the
107+
[rich_theme.py](https://github.com/python-cmd2/cmd2/blob/main/examples/rich_theme.py) example for
108+
more information.
109+
95110
After adding the desired escape sequences to your output, you should use one of these methods to
96111
present the output to the user:
97112

@@ -110,9 +125,9 @@ to control whether these escape codes are passed through to the terminal or not.
110125
If you would like to generate output which is left, center, or right aligned within a specified
111126
width or the terminal width, the following functions can help:
112127

113-
- `cmd2.utils.align_left`
114-
- `cmd2.utils.align_center`
115-
- `cmd2.utils.align_right`
128+
- `cmd2.string_utils.align_left`
129+
- `cmd2.string_utils.align_center`
130+
- `cmd2.string_utils.align_right`
116131

117132
These functions differ from Python's string justifying functions in that they support characters
118133
with display widths greater than 1. Additionally, ANSI style sequences are safely ignored and do not

docs/features/table_creation.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ excellent support for this feature.
77

88
Please see rich's documentation on [Tables](https://rich.readthedocs.io/en/latest/tables.html) for
99
more information.
10+
11+
The [rich_tables.py](https://github.com/python-cmd2/cmd2/blob/main/examples/rich_tables.py) example
12+
demonstrates how to use `rich` tables in a `cmd2` application.

docs/migrating/next_steps.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ If your program generates output by printing directly to `sys.stdout`, you shoul
4141
to `cmd2.Cmd.poutput`, `cmd2.Cmd.perror`, and `cmd2.Cmd.pfeedback`. These methods work with several
4242
of the built in [Settings](../features/settings.md) to allow the user to view or suppress feedback
4343
(i.e. progress or status output). They also properly handle ANSI colored output according to user
44-
preference. Speaking of colored output, you can use any color library you want, or use the included
45-
`cmd2.string_utils.stylize` function. These and other related topics are covered in
46-
[Generating Output](../features/generating_output.md).
44+
preference. `cmd2`'s dependency on `rich` makes it easy to add color and style to your output. See
45+
the [Colored Output](../features/generating_output.md#colored-output) section for more details.
46+
These and other related topics are covered in [Generating Output](../features/generating_output.md).

0 commit comments

Comments
 (0)