Omit hidden commands and options from typer utils docs output#1750
Open
CaxiLee wants to merge 2 commits into
Open
Omit hidden commands and options from typer utils docs output#1750CaxiLee wants to merge 2 commits into
CaxiLee wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_clickintyper/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_helpintyper/rich_utils.py.Changes
typer/cli.py—get_docs_for_clickhiddenattribute is true (same idea as Rich help).click.Groupapps, build the Commands list and the recursive doc sections only from subcommands that are not hidden (instead of iterating every name returned bylist_commands).tests/test_cli_docs_hidden.pyhidden=Truesubcommand does not.hidden=Trueoption does not.How to test
From the repository root: