Display command aliases in generated man-pages#891
Conversation
|
Thanks for the contribution, do you have another reference for this:
|
|
You're right,
And the convention is documented in
That is, in executable sections (1, 6, 8), repeated |
21ad6a5 to
3b19f7b
Compare
Subcommand aliases already surface in --help and dump-help, but the generate-manual tool ignored CommandInfoV0.aliases. Single-page output now lists aliases inline with the subcommand name (e.g. "multiply, mul"), matching the --help format. Multi-page output lists aliases as comma-separated .Nm entries in the NAME section, following the BSD mdoc convention (see ls(1)). Resolves apple#851.
3b19f7b to
d82d90d
Compare
Resolves #851 (and partially addresses the umbrella #849).
Subcommand aliases already flow through
CommandInfoV0.aliasesand surface in--helpand dump-help output, but thegenerate-manualtool never consumed them.Changes
Tools/generate-manual/Extensions/ArgumentParser+MDoc.swift: newmanualPageSubcommandLabelhelper that returnscommandNamealone, or"commandName, alias1, alias2"when aliases exist. Mirrors the format used byHelpGenerator.Tools/generate-manual/DSL/SinglePageDescription.swift: use the helper when rendering each subcommand list item.Tools/generate-manual/DSL/Name.swift: emit one.Nmmacro per alias in the NAME section. This is the canonical BSD mdoc convention (seels(1), which listsls, dirin NAME).testMath*Manualsnapshots. The other ten snapshots are unchanged because theguardinmanualPageSubcommandLabelshort-circuits for commands without aliases, so output for alias-less commands is byte-identical.Example output
Single-page (Math example, subcommand list):
Multi-page (NAME section on each subcommand page):
Scope decisions
SeeAlso.swift: left alone. It cross-references other man-pages, and aliases do not generate their own pages.Synopsis.swift: left alone. The bare.Nmauto-resolves to the first.Nmin the document, which remains the primary name.MultiPageDescription.swift: does not iterate subcommands, so no change needed.Test plan
swift test --filter GenerateManualTestspasses (12/12)mulandavgaliases via PR Add aliases support for sub commands #627) now renders them in both single-page and multi-page output