Repository navigation
Conversation
Fixes spf13#2520 Since go-md2man v2 (cobra v0.0.6), the tab-indented usage line after each flag is joined with the flag into one paragraph, so man pages show the description on the same line as the flag. Write the usage as a go-md2man definition list instead, which renders as .TP. Escape list and heading markers at the start of usage lines and indent the following lines, so multi-line usages stay inside the definition.
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.
Closes #2520
manPrintFlagsnow writes the flag usage as a go-md2man definition list (: usage), which renders as.TP. gh uses the same form in its copy of the generator.A definition list alone isn't enough, because go-md2man still reads the usage as Markdown. It turns a usage line starting with
-,*,+or1.into a list and indents all following flags by 2 instead of 7. A blank line in the usage ends the definition, and the next paragraph loses its indent. The fix escapes these markers at the start of each line and indents the following lines by four spaces.The escaping also fixes an existing bug. Until now, a usage line starting with
#turned into a section heading, and all following flags ended up under it.TestGenManFlagsAsTaggedParagraphscovers these cases.TestManPrintFlagsHidesShortDeprecatednow expects the definition list instead of the tab-indented line.I built docker, hugo, restic, caddy and helm against this branch and generated their man pages. Every flag now renders as
.TP. The text of the pages is unchanged, only the flag layout differs.restic's
restic-backup.1, before and after (MANWIDTH=80):