rich_click.rich_help_formatter
Attributes
| Name | Description |
|---|---|
RP | No description. |
Classes
| Name | Description |
|---|---|
RichHelpFormatter | Rich Help Formatter. |
Functions
| Name | Description |
|---|---|
create_console | Create a Rich console from a help configuration. |
RichHelpFormatterclass#
class RichHelpFormatter(indent_increment: int = 2, width: int | None = None, max_width: int | None = None, *args: Any, console: Console | None = None, config: RichHelpConfiguration | None = None, export_console_as: Literal[None, 'html', 'svg', 'text'] = None, export_kwargs: dict[str, Any] | None = None, **kwargs: Any)Bases: click.HelpFormatter
Rich Help Formatter.
This class is a container for the help configuration and Rich Console that are used internally by the help and error printing methods.
Create Rich Help Formatter.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
indent_increment | int | 2 | Passed to click.HelpFormatter. |
width | int | None | None | Passed to click.HelpFormatter. Overrides config.width if not None. |
max_width | int | None | None | Passed to click.HelpFormatter. Overrides config.max_width if not None. |
*args | Any | () | Args passed to click.HelpFormatter. |
console | Console | None | None | Use an external console. |
config | RichHelpConfiguration | None | None | RichHelpConfiguration. If None, then build config from globals. |
export_console_as | Literal[None, 'html', 'svg', 'text'] | None | How output is rendered by getvalue(). Default of None renders output normally. |
export_kwargs | dict[str, Any] | None | None | Any kwargs passed to the export method of the Console in getvalue(). |
**kwargs | Any | {} | Kwargs passed to click.HelpFormatter. |
command_panel_classattributeclass attributeinstance attribute#
command_panel_class: type[RichCommandPanel] = RichCommandPanelconfigattributeinstance attribute#
config = configconsoleattributeinstance attribute#
console: ConsoleRich Console created from the help configuration.
This console is meant only for use with the formatter and should not be created directly
export_console_asattributeclass attributeinstance attribute#
export_console_as: Literal[None, 'html', 'svg', 'text'] = export_console_asexport_kwargsattributeinstance attribute#
export_kwargs = export_kwargs or {}option_panel_classattributeclass attributeinstance attribute#
option_panel_class: type[RichOptionPanel] = RichOptionPanelhighlighterpropertycached#
highlighter: Highlighterwidthpropertywritable#
width: intdedentmethod#
def dedent() -> Nonegetvaluemethod#
def getvalue() -> strindentmethod#
def indent() -> Noneindentationmethod#
def indentation() -> Iterator[None]rich_textmethod#
def rich_text(text: str | Text | Markdown, style: StyleType = '') -> Text | Markdown | RichClickRSTTake a string, remove indentations, and return styled text. By default, return the text as a Rich Text with the request style.
This method uses the config options prefixed text_ to influence how
rendering works.
Parameters
sectionmethod#
def section(name: str) -> Iterator[None]writemethod#
def write(*objects: Any, **kwargs: Any) -> Nonewrite_abortmethod#
def write_abort() -> NonePrint richly formatted abort error.
write_dlmethod#
def write_dl(rows: Iterable[tuple[str, str]], col_max: int = 30, col_spacing: int = 2) -> Nonewrite_errormethod#
def write_error(e: click.ClickException) -> Nonewrite_headingmethod#
def write_heading(heading: str) -> Nonewrite_paragraphmethod#
def write_paragraph() -> Nonewrite_textmethod#
def write_text(text: str) -> Nonewrite_usagemethod#
def write_usage(prog: str, args: str = '', prefix: str | None = None) -> Nonecreate_consolefunction#
def create_console(config: RichHelpConfiguration, file: IO[str] | None = None, width: int | None = None, max_width: int | None = None) -> ConsoleCreate a Rich console from a help configuration.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
config | RichHelpConfiguration | required | Help configuration to take the console settings from. |
file | IO[str] | None | None | Stream to write to. If not set, the console records its output to an in-memory buffer. |
width | int | None | None | Width of the console. Overrides config.width. |
max_width | int | None | None | Maximum width of the console. Overrides config.max_width. |
Returns
Console- The new console.