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

[JavadocType] add additional allowedTags feature #14724

Open
xenoterracide opened this issue Mar 27, 2024 · 1 comment
Open

[JavadocType] add additional allowedTags feature #14724

xenoterracide opened this issue Mar 27, 2024 · 1 comment

Comments

@xenoterracide
Copy link

xenoterracide commented Mar 27, 2024

Since, java 8 there are new javadoc tags, but you can also add arbitrary ones

https://nipafx.dev/javadoc-tags-apiNote-implSpec-implNote/

How it works Now:

/**
 * Interface for objects that have a name.
 *
 * @apiNote you must implement one of {@link #getName()} or {@link #name()}.
 */
interface Nameable {}
[ant:checkstyle] [ERROR] /home/xeno/IdeaProjects/spring-app-commons/module/model/src/main/java/com/xenoterracide/model/Nameable.java:11:4: Unknown tag 'apiNote'. [JavadocType]

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Although the tags mentioned above are used by java itself, they aren't enabled by default, and you have to pass options to javadoc to use them. note: the weird quoting mentioned in the doc appears to be a shell escape as it's completely irrelevant in gradle

tasks.withType<Javadoc>().configureEach {
  (options as StandardJavadocDocletOptions).apply {
    addMultilineStringsOption("tag").value = listOf(
      "apiSpec:a:API Spec:",
      "apiNote:a:API Note:",
      "implSpec:a:Implementation Spec:",
      "implNote:a:Implementation Note:",
    )
  }
}

I think the best option is to introduce a property of "additional tags"

      <property name="additionalTags" value="apiNote,apiSpec,implNote,implSpec,arbitraryInput" />

Additional context

it might be reasonable to consider adding apiNote,apiSpec,implNote,implSpec as either defaults for this new property, or just have them be recognized without that. I'm indifferent. I just don't like the idea that by allowing unknown tags, it means anything. Meaning typos won't be caught, or other junk.

@sktpy
Copy link
Contributor

sktpy commented Mar 27, 2024

In the meantime you can suppress violation as done in #14618 (comment).

It is highly likely that property would not be added until the check is redesigned to be AST based,
and in my opinion it shouldn't be added until the redesign is done because the current implementation is not reliable to detect various tag formats that is used for such cases.

I just don't like the idea that by allowing unknown tags, it means anything.

I agree with this. #14618 (comment)

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

No branches or pull requests

2 participants