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

doc: adding Javadoc tags to CtImport #6171

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rishivijayv
Copy link
Contributor

#3923

This adds Javadoc tags (@param and @return) to the methods of the CtImport interface. Using the check-javadoc-regressions.py now does not show any Javadoc errors in the CtImport.java file.

Before the change

$ chore/run-with-spoon-javadoc-classpath.sh chore/CheckJavadoc.java
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J(W): Ignoring binding found at [jar:file:/Users/rishivijayvargiya/.m2/repository/org/slf4j/slf4j-nop/1.7.36/slf4j-nop-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
[ERROR] src/main/java/spoon/reflect/declaration/CtImport.java:40:15: Missing @return tag in getImportKind()
[ERROR] src/main/java/spoon/reflect/declaration/CtImport.java:46:14: Missing @return tag in getReference()
[ERROR] src/main/java/spoon/reflect/declaration/CtImport.java:53:25: Missing @param 'reference' tag in setReference(CtReference)
[ERROR] src/main/java/spoon/reflect/declaration/CtImport.java:53:25: Missing @param '<T>' tag in setReference(CtReference)
[ERROR] src/main/java/spoon/reflect/declaration/CtImport.java:53:25: Missing @return tag in setReference(CtReference)
[ERROR] src/main/java/spoon/reflect/declaration/CtImport.java:58:7: Missing @param 'visitor' tag in accept(CtImportVisitor)

After the change

$ chore/run-with-spoon-javadoc-classpath.sh chore/CheckJavadoc.java
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J(W): Ignoring binding found at [jar:file:/Users/rishivijayvargiya/.m2/repository/org/slf4j/slf4j-nop/1.7.36/slf4j-nop-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.

@@ -34,26 +34,31 @@
*/
public interface CtImport extends CtElement {
/**
* Returns the kind of import (see {@link CtImportKind})
* @return The kind of import (see {@link CtImportKind})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://stackoverflow.com/a/25957713, it seems that only having tags without a main description section is also acceptable. So adopting that approach here as I think that avoids some repetition.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "modern" way is using the inline returns tag: {@return the kind of import...}. This will automatically create a doc comment body in the expected format for you. See https://docs.oracle.com/en/java/javase/22/docs/specs/javadoc/doc-comment-spec.html#return :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh should have scrolled a little further down the very link that I posted here haha 😅 This is pretty nifty, thanks! Adjusted now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants