Skip to content

Omit hidden commands and options from typer utils docs output#1750

Open
CaxiLee wants to merge 2 commits into
fastapi:masterfrom
CaxiLee:fix/docs-respect-hidden
Open

Omit hidden commands and options from typer utils docs output#1750
CaxiLee wants to merge 2 commits into
fastapi:masterfrom
CaxiLee:fix/docs-respect-hidden

Conversation

@CaxiLee
Copy link
Copy Markdown

@CaxiLee CaxiLee commented May 16, 2026

Motivation

Typer’s interactive help (Rich) skips parameters and subcommands marked with hidden=True, so end users do not see internal or deprecated flags/commands when they run --help.

The Markdown generator used by typer … utils docs (get_docs_for_click in typer/cli.py) did not apply the same rules: hidden options/arguments could still appear under Options / Arguments, and hidden subcommands were still listed under Commands and received nested documentation sections. That made generated docs inconsistent with the CLI and could unintentionally publish “hidden” surface area.

This change aligns generated Markdown with the behavior of rich_format_help in typer/rich_utils.py.

Changes

  • typer/cli.pyget_docs_for_click

    • When collecting help records for arguments and options, skip any parameter whose hidden attribute is true (same idea as Rich help).
    • For click.Group apps, build the Commands list and the recursive doc sections only from subcommands that are not hidden (instead of iterating every name returned by list_commands).
  • tests/test_cli_docs_hidden.py

    • Assert that a visible subcommand appears in the Markdown while a hidden=True subcommand does not.
    • Assert that a visible option appears while a hidden=True option does not.

How to test

From the repository root:

pytest tests/test_cli_docs_hidden.py -q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants