Skip to content

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

Draft
CaxiLee wants to merge 3 commits into
fastapi:masterfrom
CaxiLee:fix/docs-respect-hidden
Draft

Omit hidden commands and options from typer utils docs output#1750
CaxiLee wants to merge 3 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

@svlandeg svlandeg marked this pull request as draft May 18, 2026 06:49
@svlandeg svlandeg added the feature New feature, enhancement or request label May 18, 2026
Copy link
Copy Markdown
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting this in draft as long as the CI is failing. Feel free to mark as "ready for review" when everything is green! 🙏

@github-actions github-actions Bot removed the waiting label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature, enhancement or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants