Skip to content

Commit 8e64642

Browse files
committed
Improved styles.py documentation.
1 parent e7bce66 commit 8e64642

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

cmd2/styles.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
"""Defines custom Rich styles and their corresponding names for cmd2.
22
3-
This module provides a centralized and discoverable way to manage Rich styles used
4-
within the cmd2 framework. It defines a StrEnum for style names and a dictionary
5-
that maps these names to their default style objects.
3+
This module provides a centralized and discoverable way to manage Rich styles
4+
used within the cmd2 framework. It defines a StrEnum for style names and a
5+
dictionary that maps these names to their default style objects.
6+
7+
**Notes**
8+
9+
Cmd2 uses Rich for its terminal output, and while this module defines a set of
10+
cmd2-specific styles, it's important to understand that these aren't the only
11+
styles that can appear. Components like Rich tracebacks and the rich-argparse
12+
library, which cmd2 uses for its help output, also apply their own built-in
13+
styles. Additionally, app developers may use other Rich objects that have
14+
their own default styles.
15+
16+
For a complete theming experience, you can create a custom theme that includes
17+
styles from Rich and rich-argparse. The `cmd2.rich_utils.set_theme()` function
18+
automatically updates rich-argparse's styles with any custom styles provided in
19+
your theme dictionary, so you don't have to modify them directly.
20+
21+
You can find Rich's default styles in the `rich.default_styles` module.
22+
For rich-argparse, the style names are defined in the
23+
`rich_argparse.RichHelpFormatter.styles` dictionary.
24+
625
"""
726

827
import sys
@@ -26,7 +45,7 @@ class Cmd2Style(StrEnum):
2645
Using this enum allows for autocompletion and prevents typos when
2746
referencing cmd2-specific styles.
2847
29-
This StrEnum is tightly coupled with DEFAULT_CMD2_STYLES. Any name
48+
This StrEnum is tightly coupled with `DEFAULT_CMD2_STYLES`. Any name
3049
added here must have a corresponding style definition there.
3150
"""
3251

0 commit comments

Comments
 (0)