-
Notifications
You must be signed in to change notification settings - Fork 23
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
Feature request: clearer visual for optional parameters #138
Comments
Optional function arguments are already covered in the "Writing Types" page: |
Yes, I am currently writing them in the way described on that page as a union with nil. My request is to change how they appear - I have updated the title to clarify. For a seasoned lua veteran, it's obvious that a union with The |
I think I find the (optional) text afterwards a little bit harder to parse quickly than a question mark after the parameter name. It might be valuable to normalize the types to one style though instead of having |
Normalizing would definitely help me. If whatever indication is used has a separate css class that would solve all of my problems. I'll note that I found the Types page a tiny bit confusing when I was first looking - I think |
In Lua documentation I'm able to mark a parameter as optional by setting the type to be
(type|nil)
(like@param optionalNum (number|nil) -- Optional number, defaults to 0
. Some parsers, including Luau and VSCode's language server for Lua, support a question mark to mark a parameter as optional. (like@param optionalNum number? -- Optional number, defaults to 0
) I'd like to see moonwave support both of these in a clear way.Moonwave currently renders the nil union option just as the user wrote it, which is reasonable. I'd find it more useful if it translated this to marking the parameter as optional in documentation, though.
My proposal:
?
, it should be translated to(existing type[s] | nil)
nil
, the parameter should be visually marked as optional. Nil should be removed from rendered type unionsHere's a quick mockup of what it might look like:
ps: Thanks for writing this! I'm really appreciating having a node-based documentation tool for lua, especially one I'll be able to theme.
Semi-related to #4
The text was updated successfully, but these errors were encountered: