Skip to content

Fix docc-reference rendering of short and single-dash names - #991

Open
awaisdev5765 wants to merge 2 commits into
apple:mainfrom
awaisdev5765:fix-docc-short-names
Open

awaisdev5765 wants to merge 2 commits into
apple:mainfrom
awaisdev5765:fix-docc-short-names

Conversation

@awaisdev5765

Copy link
Copy Markdown

Fixes #989

Problem

generate-docc-reference filtered argument names to long names only and hardcoded the -- prefix, so flags and options declared with only a short name or a single-dash long name rendered as a bare -- in both the usage synopsis and the argument list.

Fix

Names are now rendered with the dash prefix matching their kind, the same way generate-manual does (ArgumentInfoV0.NameInfoV0 → -v / -level / --verbose). Long names are still preferred when available, so output for existing tools is unchanged.

Before

so [--] [--=<n>] [--=<level>] [--help]

After

so [-v] [-n=<n>] [-level=<level>] [--help]

Testing

  • Added a new name-varieties example exercising every name kind: short-only flag, short+long flag, short-only option, single-dash-long option, and long-only option.
  • Added nameVarietiesMarkdownReference and nameVarietiesDoccReference snapshot tests covering both output styles.
  • All 10 existing docc-reference snapshot tests pass byte-identical (confirming no regression for tools with long names).
  • Full suite: 574 tests in 57 suites, all passing.

generate-docc-reference previously filtered argument names to long names
only and hardcoded the '--' prefix, so flags and options declared with
only a short name or a single-dash long name rendered as a bare '--' in
both the usage synopsis and the argument list.

Names are now rendered with the dash prefix matching their kind (like
generate-manual does), preferring long names when available to keep
existing output stable. A new 'name-varieties' example exercises every
name kind, with snapshot tests covering both markdown styles.

Fixes apple#989
Bash function names may not contain hyphens; replace hyphens with
underscores in helper and per-command completion function names and in
the complete -F registration. Subcommand names in case statements are
unaffected.

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

2 participants