tests.test_command_doc module¶
- tests.test_command_doc.test_no_rewrap_marker_becomes_no_fill()[source]¶
Click’s
\bmarker must produce a roff.nf/.fiblock (click-man #9).
- tests.test_command_doc.test_no_rewrap_marker_does_not_leak_into_surrounding_paragraphs()[source]¶
A
\bparagraph must not switch the whole DESCRIPTION to preformatted mode: prose before and after stays filled, only the marked paragraph lands between.nf/.fi.
- tests.test_command_doc.test_name_line_keeps_full_short_help()[source]¶
The NAME
.SHline carries the canonical description without Click’s 45-char terminal truncation.
- tests.test_command_doc.test_inline_literal_in_short_help_renders_as_bold()[source]¶
Inline reST literals (
..) in the first docstring line land on the NAME.SHline as\fB..\fR, not as raw backticks (which mandoc renders as quote characters).
- tests.test_command_doc.test_inline_literal_in_description_renders_as_bold()[source]¶
Inline reST literals in the description body become
\fB..\fRso mandoc’s HTML output shows them in bold rather than wrapped in Unicode quote characters.
- tests.test_command_doc.test_boolean_flag_renders_both_spellings()[source]¶
--ascii/--no-asciimust both appear (click-man #41).
- tests.test_command_doc.test_option_groups_become_subsections()[source]¶
An explicit option group renders as a roff
.SSsubsection of OPTIONS, with the ungrouped remainder gathered underOther options.
- tests.test_command_doc.test_default_option_groups_close_the_options_section(subject, own_section)[source]¶
The sections of
DEFAULT_OPTION_GROUPStrail a command’s own options.They land past the ungrouped remainder, in the order the taxonomy declares, matching what
--helpdraws.
- tests.test_command_doc.test_ungrouped_command_has_no_subsections()[source]¶
A command carrying no option group at all keeps a flat OPTIONS list.
- tests.test_command_doc.test_dynamic_subcommand_discovered()[source]¶
Dynamically-resolved subcommands must be generated (click-man #14 / #56).
- tests.test_command_doc.test_environment_section_deduplicated()[source]¶
A shared env var (
--config/--no-config) appears only once.
- tests.test_command_doc.test_authors_omitted_without_metadata()[source]¶
No distribution matches the command name, so AUTHORS is dropped rather than synthesized from a fallback.
- tests.test_command_doc.test_man_option_reads_the_manual()[source]¶
--mantypesets the page for reading, the waymanitself does.
- tests.test_command_doc.test_strip_overstrike(text, expected)[source]¶
Bold and underline pairs both collapse to their plain character.
- tests.test_command_doc.test_find_typesetters_fills_each_installed_one(monkeypatch)[source]¶
Each installed program yields its resolved path and its filled arguments.
- tests.test_command_doc.test_man_option_falls_back_to_the_source(monkeypatch)[source]¶
With no typesetter installed, the source beats an error.
- tests.test_command_doc.test_accessible_manual_drops_overstrike()[source]¶
Accessible mode strips the emphasis a screen reader would voice as noise.
- tests.test_command_doc.test_generated_roff_passes_groff_lint(cli, prog_name)[source]¶
Every generated page must parse cleanly under groff (no warnings).
forecastexercises the.SSoption-group subsections.
- tests.test_command_doc.test_render_help_rejects_unknown_format()[source]¶
An unknown format names the ones that exist instead of failing blankly.
- tests.test_command_doc.test_help_formats_describe_every_format()[source]¶
Every
HelpFormathas a description, and members run alphabetically.
- tests.test_command_doc.test_render_help_takes_a_member_or_its_value(help_format)[source]¶
A
HelpFormatmember and its string value render the same document.
- tests.test_command_doc.test_render_help_names_carapace_spec_after_prog_name(prog_name, spec_name)[source]¶
A passed
prog_namenames a Carapace spec, over the command’s own name.
- tests.test_command_doc.test_json_carries_every_section()[source]¶
The JSON document covers what the man page covers, as native types.
- tests.test_command_doc.test_json_carries_choices_a_short_metavar_hides()[source]¶
A consumer reads the accepted values off
choices, never off the metavar.An option overriding the metavar with a short placeholder leaves nothing to parse in
metavar, which is the whole reason the key is separate.
- tests.test_command_doc.test_json_reports_no_choices_for_an_open_type()[source]¶
choicesisNonefor a type that enumerates nothing.
- tests.test_command_doc.test_a_short_metavar_lists_its_values_in_the_render(help_format)[source]¶
Shortening the metavar moves the values below the help, never drops them.
- tests.test_command_doc.test_a_default_choice_metavar_does_not_repeat_its_values(help_format)[source]¶
A
[a|b]metavar already shows them, so nothing is appended below it.
- tests.test_command_doc.test_every_enumerated_default_option_reaches_the_render(help_format)[source]¶
No default option hides its accepted values behind a short metavar.
--table-formatand--export-configboth trade the[a|b|c]metavar for a one-word placeholder to keep the help screen readable. That is a help-screen decision, and it must not reach the man page or the Markdown render, which are what a reader consults precisely to learn what a value may be.
- tests.test_command_doc.test_json_lists_subcommands_by_name_only()[source]¶
Progressive disclosure: children are named, never recursively expanded.
- tests.test_command_doc.test_subcommand_aliases_reach_every_backend()[source]¶
A generated page names the short spelling the help screen advertises.
An alias is invocable, so a reader who only ever sees the man page or the JSON export would otherwise never learn it exists.
- tests.test_command_doc.test_json_full_walks_the_whole_tree()[source]¶
The -full variant is the one that expands every command of the tree.
- tests.test_command_doc.test_markdown_renders_every_section()[source]¶
The Markdown document carries the same sections as headings.
- tests.test_command_doc.test_markdown_full_walks_the_whole_tree()[source]¶
Every command of the tree gets its own title in one document.
- tests.test_command_doc.test_no_rewrap_marker_keeps_its_shape_in_markdown()[source]¶
A
\bregion is fenced rather than reflowed into a paragraph.
- tests.test_command_doc.test_markdown_escapes_html_characters_outside_code_spans()[source]¶
Help prose shows as written, where Markdown would read it as HTML.
A browser shows nothing for
<guests>, which Markdown takes for a tag. A code span keeps its content as written, whether a reST literal made it or the author wrote it.
- tests.test_command_doc.test_examples_render_in_every_backend()[source]¶
One
examples=declaration feeds the help screen, roff, Markdown and JSON.
- tests.test_command_doc.test_command_without_examples_grows_no_section()[source]¶
A command declaring no example renders no section for them.
- tests.test_command_doc.test_malformed_examples_fail_at_construction(malformed)[source]¶
A bad pair surfaces on import, not on the first –help a user runs.
- tests.test_command_doc.test_dynamic_help_is_extracted()[source]¶
Options computing their help from the context are not left blank.
-v/-qleaveOption.helpat None and build their sentence inget_help_record(). Every backend here reads the extracted model, so the text has to be resolved once, at extraction.
- tests.test_command_doc.test_registered_name_names_the_page()[source]¶
A subcommand registered under another name is documented under that name.
The COMMANDS section lists
predict, so the page a reader looks for isweather-predict.1, and its NAME line saysweather predict: the name the parent registered wins over the command’s own.
- class tests.test_command_doc.Fruit(*values)[source]¶
Bases:
EnumChoices an option can take as
Enummembers.- APPLE = 'apple'¶
- BANANA = 'banana'¶
- tests.test_command_doc.test_enum_choices_are_spelled_as_click_completes_them(help_format, expected)[source]¶
An
Enumchoice lists its member names, the spelling Click accepts.str()of a member readsFruit.APPLE, which no invocation can type. The short metavar hides the values, so the render adds them back and shows which spelling the document carries.
- tests.test_command_doc.test_install_manpages_resolves_home_at_call_time(tmp_path, monkeypatch)[source]¶
The pages land under the
HOMEin force at the call, not at import.With no
XDG_DATA_HOMEset, the default directory derives from the home directory. A test fixture or a packaging script pointingHOMEelsewhere for one invocation is honored, which a path expanded at import cannot do.