-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Scaladoc tool: render @deprecated
correctly even when named arguments weren't used
#21925
base: main
Are you sure you want to change the base?
Conversation
I'm busy at the Lightbend company meeting the whole rest of the week, then I have some vacation days, so the earliest I could return to it is around Nov 21. @HarrisL2 feel free to run with it if you like. if you end up not having time either, I'll come back to it eventually |
@deprecated
correctly even when named arguments weren't used
I'm not able to write a test case for this change without making really specific checks. Ideally it would be a general test framework like SignatureTest.scala, where we can check the generated attributes of each member with an expected result. I don't think this framework exists at the moment. There are test cases about annotations, but those are for annotations that affect the generated signature, whereas the I have added test cases to scaladoc-testcases/src/tests/deprecated.scala, but it should be noted that it currently does not check the behavior of annotations. It only checks signatures through Deprecated in TranslatableSignaturesTestCases.scala. |
cdea6b8
to
61dc746
Compare
I hope this PR will be considered mergeable even though our ambition level stopped short of proper automated testing for it. A JSoup-based test would be annoying fragile, I think. I've rebased it and marked it ready for review. @KacperFKorban I'm not sure if you're currently available for reviewing this sort of PR; let me know if you think we should try to find a different reviewer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix, it looks good overall!
I wouldn't stress about adding tests for annotations, you would have to implement the whole infrastructure for it as well 😅
I added a small style related suggestion.
val message: Option[Annotation.AnnotationParameter] = | ||
a.params.filter(p => p.name.isEmpty || p.name.get != "since").lift(0) | ||
val since: Option[Annotation.AnnotationParameter] = | ||
a.params.filter(_.name.nonEmpty).find(_.name.get == "since").orElse(a.params.lift(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this logic somewhat hard to read and dependent on the definition of deprecated
(which doesn't have to be bad).
Could you instead do a two step processing? i.e.
- Collect all named arguments into a map
- For all non-named arguments, map them to the remaining names positionally
It's not a hard preference though, so just let me know if you prefer to rephrase it or stay with the current approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've adjusted the syntax, hopefully it makes the logic clearer.
Fixes #20118
Still need a test case for this issue using jsoup