Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ee6932c
Add support for commands' rich_help_panel in generated docs
kinuax May 9, 2024
b802512
Fix type
kinuax May 10, 2024
80f27a3
Add tests with combination of panels
kinuax May 10, 2024
760cf3c
Avoid assignment expressions
kinuax May 17, 2024
99e1477
Mix default and custom commands in same app
kinuax May 17, 2024
87f7e2d
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax May 17, 2024
c0af3cd
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax Aug 16, 2024
bc937f2
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
svlandeg Aug 28, 2025
ac013b3
update expected output according to new functionality on master
svlandeg Aug 28, 2025
90d1b3d
remove duplicate part
svlandeg Aug 28, 2025
6386af3
fix output according to new behaviour on master
svlandeg Aug 28, 2025
b19abe9
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
svlandeg Sep 9, 2025
a0598b5
ensure robustness against rich imports
svlandeg Sep 9, 2025
7d3e71c
fix type annotations
svlandeg Sep 9, 2025
354fe9b
cleanup
svlandeg Sep 9, 2025
27445a8
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax Sep 22, 2025
59108e5
Fix name
kinuax Sep 22, 2025
9d691e6
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax Sep 30, 2025
b58ae12
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
svlandeg Nov 25, 2025
ed0164b
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax Dec 9, 2025
82b3853
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
svlandeg Jan 9, 2026
9b4e73c
🎨 Auto format
pre-commit-ci-lite[bot] Jan 9, 2026
a7007dd
fix separator
svlandeg Jan 9, 2026
9d53174
Merge branch 'add-support-for-rich_help_panel-in-generated-docs' of h…
svlandeg Jan 9, 2026
bed0785
fix import
svlandeg Jan 9, 2026
c06352a
don't show the headers if Rich is disabled
svlandeg Jan 9, 2026
d4c82b0
🎨 Auto format
pre-commit-ci-lite[bot] Jan 9, 2026
ad2211b
fix formatting
svlandeg Jan 9, 2026
011a918
Merge branch 'add-support-for-rich_help_panel-in-generated-docs' of h…
svlandeg Jan 9, 2026
d69da77
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax Feb 22, 2026
37a1513
use | instead of Union
svlandeg Feb 25, 2026
a8b5fd6
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
svlandeg Feb 25, 2026
36922be
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax Mar 12, 2026
17708dc
Merge branch 'master' into add-support-for-rich_help_panel-in-generat…
kinuax May 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/assets/cli/multi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def hello(name: str = "World", age: int = typer.Option(0, help="The age of the u
typer.echo(f"Hello {name}")


@sub_app.command()
@sub_app.command(rich_help_panel="Greet")
def hi(user: str = typer.Argument("World", help="The name of the user to greet")):
"""
Say Hi
"""


@sub_app.command()
@sub_app.command(rich_help_panel="Farewell")
def bye():
"""
Say bye
Expand All @@ -32,7 +32,7 @@ def bye():
app.add_typer(sub_app, name="sub")


@app.command()
@app.command(rich_help_panel="")
def top():
"""
Top command
Expand Down
6 changes: 6 additions & 0 deletions tests/assets/cli/multiapp-docs-title.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ $ multiapp sub [OPTIONS] COMMAND [ARGS]...
**Commands**:

* `hello`: Say Hello

**Greet**:

* `hi`: Say Hi

**Farewell**:

* `bye`: Say bye

### `multiapp sub hello`
Expand Down
6 changes: 6 additions & 0 deletions tests/assets/cli/multiapp-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ $ multiapp sub [OPTIONS] COMMAND [ARGS]...
**Commands**:

* `hello`: Say Hello

**Greet**:

* `hi`: Say Hi

**Farewell**:

* `bye`: Say bye

### `multiapp sub hello`
Expand Down
37 changes: 27 additions & 10 deletions typer/cli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import importlib.util
import re
import sys
from collections import defaultdict
from itertools import chain
from pathlib import Path
from typing import Any, List, Optional
from typing import Any, Dict, List, Optional

import click
import typer
import typer.core
from click import Command, Group, Option
from typer.rich_utils import _RICH_HELP_PANEL_NAME, COMMANDS_PANEL_TITLE
Comment thread
svlandeg marked this conversation as resolved.
Outdated

from . import __version__

Expand Down Expand Up @@ -250,19 +253,33 @@ def get_docs_for_click(
group = obj
commands = group.list_commands(ctx)
if commands:
docs += "**Commands**:\n\n"
panel_to_commands: Dict[str, List[click.Command]] = defaultdict(list)
for command in commands:
command_obj = group.get_command(ctx, command)
assert command_obj
docs += f"* `{command_obj.name}`"
command_help = command_obj.get_short_help_str()
if command_help:
docs += f": {_parse_html(command_help)}"
panel_name = (
getattr(command_obj, _RICH_HELP_PANEL_NAME, None)
or COMMANDS_PANEL_TITLE
)
panel_to_commands[panel_name].append(command_obj)
default_command_objs = panel_to_commands.pop(COMMANDS_PANEL_TITLE, [])
if default_command_objs:
panel_to_commands = {
COMMANDS_PANEL_TITLE: default_command_objs,
**panel_to_commands,
}
for panel_name, command_objs in panel_to_commands.items():
docs += f"**{panel_name}**:\n\n"
for command_obj in command_objs:
docs += f"* `{command_obj.name}`"
command_help = command_obj.get_short_help_str()
if command_help:
docs += f": {_parse_html(command_help)}"
docs += "\n"
docs += "\n"
docs += "\n"
for command in commands:
command_obj = group.get_command(ctx, command)
assert command_obj
for command_obj in chain.from_iterable(
command_objs for command_objs in panel_to_commands.values()
):
use_prefix = ""
if command_name:
use_prefix += f"{command_name}"
Expand Down
Loading