Skip to content

rich_click.rich_help_rendering

Attributes

NameDescription
RichPanelRowNo description.

Classes

NameDescription
RichClickRichPanelA console renderable that draws a border around its contents.

Functions

NameDescription
get_command_rich_table_rowCreate a row for the rich table corresponding with this command.
get_help_parameterBuild primary help text for a click option or argument.
get_parameter_rich_table_rowCreate a row for the rich table corresponding with this parameter.
get_rich_epilogRichly render a click Command's epilog if it exists.
get_rich_help_textWrite rich help text to the formatter if it exists.
get_rich_usageRichly render usage text.
rich_format_errorPrint richly formatted click errors.

RichPanelRowattributemodule attribute#

RichPanelRow = list[RenderableType | None]

RichClickRichPanelclass#

class RichClickRichPanel(*args: Any, title_padding: int = 1, **kwargs: Any)

Bases: Panel

A console renderable that draws a border around its contents.

This is a patched version of rich.panel.Panel that has additional features useful for rendering help text with rich-click.

Create RichClickRichPanel instance.

Parameters

NameTypeDefaultDescription
*argsAny()Args that get passed to rich.panel.Panel.
title_paddingint1Controls padding on panel title.
**kwargsAny{}Kwargs that get passed to rich.panel.Panel.

title_paddingattributeinstance attribute#

title_padding = title_padding

get_command_rich_table_rowfunction#

def get_command_rich_table_row(command: click.Command, ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None) -> RichPanelRow

Create a row for the rich table corresponding with this command.

get_help_parameterfunction#

def get_help_parameter(param: click.Argument | click.Option | RichParameter, ctx: RichContext, formatter: RichHelpFormatter) -> Columns

Build primary help text for a click option or argument. Returns the prose help text for an option or argument, rendered either as a Rich Text object or as Markdown. Additional elements are appended to show the default and required status if applicable.

Parameters

NameTypeDescription
paramclick.Argument | click.Option | RichParameterParameter to build help text for.
ctxRichContextClick Context object.
formatterRichHelpFormatterFormatter object.

Returns

ColumnsColumns
A columns element with multiple styled objects (help, default, required)

get_parameter_rich_table_rowfunction#

def get_parameter_rich_table_row(param: click.Argument | click.Option | RichParameter, ctx: RichContext, formatter: RichHelpFormatter, panel: RichOptionPanel | None) -> RichPanelRow

Create a row for the rich table corresponding with this parameter.

get_rich_epilogfunction#

def get_rich_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> None

Richly render a click Command’s epilog if it exists.

get_rich_help_textfunction#

def get_rich_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> None

Write rich help text to the formatter if it exists.

get_rich_usagefunction#

def get_rich_usage(formatter: RichHelpFormatter, prog: str, args: str = '', prefix: str | None = None) -> None

Richly render usage text.

rich_format_errorfunction#

def rich_format_error(formatter: RichHelpFormatter, export_console_as: Literal[None, 'html', 'svg'] = None) -> None

Print richly formatted click errors.

Called by custom exception handler to print richly formatted click errors. Mimics original click.ClickException.echo() function but with rich formatting.

Parameters

NameTypeDefaultDescription
selfclick.ClickExceptionrequiredClick exception to format.
formatterRichHelpFormatterrequiredformatter object.
export_console_asLiteral[None, 'html', 'svg']NoneIf set, outputs error message as HTML or SVG.