Skip to content

馃悰 fix: keep raw formatter after usage and render sub-command epilogs - #352

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:raw-format-epilog
Aug 27, 2026
Merged

馃悰 fix: keep raw formatter after usage and render sub-command epilogs#352
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:raw-format-epilog

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

_mk_usage replaced parser.formatter_class with a width-setting lambda and did not put the original back. The raw-formatter check in _pre_format tests issubclass(formatter, RawDescriptionHelpFormatter), so after the first usage block it answered False for the rest of the document: epilogs of a RawDescriptionHelpFormatter parser collapsed into one reflowed paragraph, descriptions did the same under :usage_first:, and group descriptions after the usage lost their line breaks as well. The repository's own epilog-multiline roots rendered a <p>, and the tests passed only because HTML source keeps newlines inside it. 馃悰

The width override now lives inside a patch.object scoped to the format_usage call, and _pre_format receives the parser whose text it renders. That second part lets sub-commands use their own formatter_class: their description goes through the same path as the root instead of a plain paragraph, and their epilog renders after the option groups, which the directive skipped before.

The directive-level :description: and :epilog: overrides keep applying to the root parser only. Sub-command descriptions still fall back to the help= string of add_parser and keep the existing whitespace strip.

@gaborbernat gaborbernat added the bug Something isn't working label Aug 27, 2026
@gaborbernat
gaborbernat force-pushed the raw-format-epilog branch 7 times, most recently from 02e3b3c to b99394a Compare August 27, 2026 16:30
_mk_usage swapped parser.formatter_class for a width-setting lambda and
left it there, so the RawDescriptionHelpFormatter check failed for every
block formatted after the first usage: epilogs, descriptions under
:usage_first:, and group descriptions all lost their line breaks.

Scope the swap with patch.object and pass the owning parser to
_pre_format, so sub-commands honour their own formatter_class. Their
description now takes the same path as the root, and their epilog
renders after the option groups instead of being dropped.
@gaborbernat
gaborbernat merged commit b69c81f into tox-dev:main Aug 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant