Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HarrisL2
Copy link
Contributor

Fixes #20118

Still need a test case for this issue using jsoup

@SethTisue SethTisue marked this pull request as draft November 11, 2024 17:49
@SethTisue SethTisue self-assigned this Nov 11, 2024
@SethTisue
Copy link
Member

SethTisue commented Nov 11, 2024

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

@SethTisue SethTisue changed the title Fix scaladoc deprecation message Scaladoc tool: render @deprecated correctly even when named arguments weren't used Nov 11, 2024
@SethTisue SethTisue added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label Nov 11, 2024
@HarrisL2
Copy link
Contributor Author

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 @deprecated annotation is a special case that is added to the attribute section, which is not tested for.

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.

@SethTisue SethTisue force-pushed the 20118 branch 2 times, most recently from cdea6b8 to 61dc746 Compare March 4, 2025 03:10
@SethTisue SethTisue requested a review from KacperFKorban March 4, 2025 03:14
@SethTisue SethTisue assigned KacperFKorban and unassigned SethTisue Mar 4, 2025
@SethTisue
Copy link
Member

SethTisue commented Mar 4, 2025

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.

@SethTisue SethTisue marked this pull request as ready for review March 4, 2025 03:17
Copy link
Member

@KacperFKorban KacperFKorban left a 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.

Comment on lines 84 to 87
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))
Copy link
Member

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.

  1. Collect all named arguments into a map
  2. 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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scaladoc does not show deprecation message
3 participants