馃悰 fix: keep raw formatter after usage and render sub-command epilogs - #352
Merged
Merged
Conversation
gaborbernat
force-pushed
the
raw-format-epilog
branch
7 times, most recently
from
August 27, 2026 16:30
02e3b3c to
b99394a
Compare
_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
force-pushed
the
raw-format-epilog
branch
from
August 27, 2026 16:33
b99394a to
aa87688
Compare
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.
_mk_usagereplacedparser.formatter_classwith a width-setting lambda and did not put the original back. The raw-formatter check in_pre_formattestsissubclass(formatter, RawDescriptionHelpFormatter), so after the first usage block it answered False for the rest of the document: epilogs of aRawDescriptionHelpFormatterparser 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 ownepilog-multilineroots rendered a<p>, and the tests passed only because HTML source keeps newlines inside it. 馃悰The width override now lives inside a
patch.objectscoped to theformat_usagecall, and_pre_formatreceives the parser whose text it renders. That second part lets sub-commands use their ownformatter_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 thehelp=string ofadd_parserand keep the existing whitespace strip.