-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for optional arguments and/or getopt-style options #51
Comments
landure
added a commit
to landure/shdoc
that referenced
this issue
Aug 17, 2023
…st#64) * Add missing empty line in overview section output. * - Add @option for short option (-o) and long options (--option). - Revamp description and titles processing to normalize "\n" usage and remove empty lines at the start and end of description. - Add dt and dd rendering styles. * Add @option to README and example. * Remove useless description self-assignation. * Fix readme width after adding too long @option * Fix readme width by shorting @see example. * Fix missing < and > escaping in outputted markdown
landure
added a commit
to landure/shdoc
that referenced
this issue
Aug 17, 2023
…st#64) * Add missing empty line in overview section output. * - Add @option for short option (-o) and long options (--option). - Revamp description and titles processing to normalize "\n" usage and remove empty lines at the start and end of description. - Add dt and dd rendering styles. * Add @option to README and example. * Remove useless description self-assignation. * Fix readme width after adding too long @option * Fix readme width by shorting @see example. * Fix missing < and > escaping in outputted markdown
landure
added a commit
to landure/shdoc
that referenced
this issue
Aug 17, 2023
…st#64) * Add missing empty line in overview section output. * - Add @option for short option (-o) and long options (--option). - Revamp description and titles processing to normalize "\n" usage and remove empty lines at the start and end of description. - Add dt and dd rendering styles. * Add @option to README and example. * Remove useless description self-assignation. * Fix readme width after adding too long @option * Fix readme width by shorting @see example. * Fix missing < and > escaping in outputted markdown
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great project! Thanks for all of your work on it 🙌🏻
Before I can convert my function docs to shdoc annotations, I need to find a way to mark arguments as optional, i.e. something equivalent to this:
A few possibilities for the melting pot of ideas:
@arg?
@arg [$2]
@arg ?$2
Non-positional arguments a.k.a. getopt-style options
I don't have suggested syntax ready to go, but annotations to add support for
getopt
-style options (flags, values, optional values) would be excellent.These are typically described as follows, where
REQUIRED
andOPTIONAL
are positional:# my_func [-f] [-w VALUE] [-wOPTIONAL_VALUE] REQUIRED [OPTIONAL...]
Caveats
More complex arrangements would probably be too difficult to design intuitive annotation syntax for and could be explained in
@description
if needed:# my_func REQUIRED_ARG [[OPTIONAL_ARG2] OPTIONAL_ARG]
That said, maybe an optional
@synopsis
tag or similar could be used to provide a compact one-line summary using agreed syntax à la docopt:# @synopsis my_func <required_arg> [[optional_arg2] optional_arg]
A default synopsis could be generated from
@arg
annotations if not given explicitly.The text was updated successfully, but these errors were encountered: