Classes
HelpState
6
▼
State for help rendering.
HelpState
6
▼
State for help rendering.
Attributes
| Name | Type | Description |
|---|---|---|
prog |
str
|
— |
description |
str
|
— |
epilog |
str
|
— |
usage |
str
|
— |
groups |
tuple[dict[str, Any], ...]
|
— |
examples |
tuple[dict[str, Any], ...]
|
— |
HelpRenderer
7
▼
Argparse formatter that renders through kida templates.
Usage::
parser = argparse.ArgumentPar…
HelpRenderer
7
▼
Argparse formatter that renders through kida templates.
Usage::
parser = argparse.ArgumentParser(
formatter_class=HelpRenderer,
)
Methods
add_text
1
▼
Capture description text before passing to base.
add_text
1
▼
def add_text(self, text: str | None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
text |
— |
start_section
1
▼
Track the current section heading.
start_section
1
▼
def start_section(self, heading: str | None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
heading |
— |
add_arguments
1
▼
Capture actions for the current section.
add_arguments
1
▼
def add_arguments(self, actions: Any) -> None
Parameters
| Name | Type | Description |
|---|---|---|
actions |
— |
end_section
0
▼
Finalize the current section and store its actions.
end_section
0
▼
def end_section(self) -> None
format_help
0
str
▼
Format help using kida template if available, else fall back to default.
format_help
0
str
▼
def format_help(self) -> str
Returns
str
Internal Methods 2 ▼
__init__
4
▼
__init__
4
▼
def __init__(self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
prog |
— |
|
indent_increment |
— |
Default:2
|
max_help_position |
— |
Default:24
|
width |
— |
Default:None
|
_render_with_template
0
str
▼
Render help through the kida help template.
Argparse reuses formatter_class fo…
_render_with_template
0
str
▼
def _render_with_template(self) -> str
Render help through the kida help template.
Argparse reuses formatter_class for non-help output (--version, add_subparsers prog extraction). In those cases no action groups are captured, so we fall back to the default argparse formatter.
Returns
str
Functions
help_formatter_with_examples
1
type[HelpRenderer]
▼
Create a HelpRenderer subclass that includes command examples.
help_formatter_with_examples
1
type[HelpRenderer]
▼
def help_formatter_with_examples(examples: tuple[dict[str, Any], ...]) -> type[HelpRenderer]
Parameters
| Name | Type | Description |
|---|---|---|
examples |
tuple[dict[str, Any], ...] |
Returns
type[HelpRenderer]