scaladoc: indicate optional parameters with = ...
#23676
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
currently, there is no indication in the scaladoc when parameters may be optional. this leads to long and overwhelming signatures which is not at all user-friendly. users are forced to first intuit that this method might have some optional parameters, then manually find the source code to learn which parameters are optional.
this PR suffixes
= ...
after the type signature of optional parameters. this makes it possible to tell that these parameters are optional and may be omitted.this applies to both method parameters and class parameters. the format is intentionally similar to the definition of such optional parameters in code:
of course, the
...
term is different. i think this is a reasonable choice because (1) ellipsis commonly represents something present but omitted, and (2) it is not valid Scala, so there is no risk someone will think this is denoting a literal default value of...
. a proper ellipsis character (rather than 3 periods) could also be considered, but i found that looked out of place amongst the monospace signature.about displaying the default value itself, this PR does not display the default value. this is because of anticipated difficulties around displaying an expression. this could be re-visited in future, but i think it should not hold up this PR. i believe that this PR alone is already a substantial improvement for the documentation of optional parameters.
finally, here is a screenshot of the scaladoc from the new optionalParams.scala test case:

this might be related to #13424