-
Notifications
You must be signed in to change notification settings - Fork 173
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
Unify the way optional params are displayed. #118
base: master
Are you sure you want to change the base?
Conversation
- Add -P,--plain_params setting for no brackets or defaults in param list. - Params with modifiers like [type=?foo] have brackets in param list. - Params with modifiers like [opt] show up as "optional" in param description.
@stevedonovan, note that mixed type modifiers like [type=?foo|bar] don't show up as optional in the description. I wasn't sure if this was a bug or intentional. Since they will show up in brackets in the param list with this patch, they should probably also show up as optional in the description, for uniformity. I wanted to check with you first before making that change, though. |
I'm having second thoughts about this part:
If those params are only followed by optional params or are at the end of the list, it's fine. But what about a function documented like this:
This implies that if you don't want to pass a "status_reason," you can call it like this (and the function will juggle the arguments):
If that's the case you could document it like this:
But what if the function does not do argument-juggling and it needs to be called like this:
In this case it shouldn't have brackets, because the brackets imply you can leave that argument out of the list entirely. Without this patch you could document it like this:
However there is no way to document an untyped, "non-juggled" parameter, e.g. [type=?], and no way to assign it a default value. I'm thinking about making the following changes:
Thoughts? |
Seven years is enough room for a lot of second thoughts. I've just picked up helping to maintain this and I'm not able to make out if this is still relevant or not. Maybe you can clue me in? |
Wow, blast from the past. I believe this was just an attempt to make optional arguments and nullable arguments end up meaning the same thing internally (that is, |
You past just landed on my present :-/ Okay I'll take a look. That conflation came up in a couple other PRs I was reviewing too: |
LDoc has two different ways to annotate optional parameters, [opt] and [type=?foo]. This patch attempts to resolve the differences in the way optional parameters display: [opt] params are shown as "optional" in the param description, and [type=?] params are shown in brackets in the param list. Also added a --plain_params setting to turn off brackets and default values in the param list.