Skip to content

Show short and single dash names in generated DocC reference - #990

Open
sebxt wants to merge 1 commit into
apple:mainfrom
sebxt:fix/docc-reference-short-only-names
Open

sebxt wants to merge 1 commit into
apple:mainfrom
sebxt:fix/docc-reference-short-only-names

Conversation

@sebxt

@sebxt sebxt commented Oct 17, 2026 •

Copy link
Copy Markdown

generate-docc-reference only kept long names when rendering a flag or option, so an argument declared with only a short name (@Flag(name: .short) var verbose) or only a single dash name was rendered as [--] in the usage block and as -- in the argument list. Options came out as --=<value>.

This change keeps using the long names when an argument has any, so existing output is unchanged. When an argument has no long name it now falls back to its preferred name with the right prefix, for example [-v] and -n=<n>. The name selection is shared by usage() and identity() in a small helper.

To cover it, the default-as-flag example gets a short only -v flag, and the DocC reference tests now run against that example in both styles. The two existing default-as-flag manual snapshots are updated for the new flag; they already rendered short only names correctly. Without the fix the new reference tests fail with [--] in place of [-v].

Tested with swift test on Linux (Swift 6.2): all 568 tests pass, and swift format lint --strict is clean on the changed files.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

Fixes #989

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
@sebxt
sebxt force-pushed the fix/docc-reference-short-only-names branch from 4ce93ff to 192957a Compare October 17, 2026 23:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate-docc-reference prints "--" for flags and options that have no long name

1 participant