Skip to content

Add checks for Documentation Comments Style Guide - Notes #19808

@gianmarcoschifone

Description

@gianmarcoschifone

Parent issue: #19807

Coverage table

Notes

Chapter link

Content

Image

Image

Text

  • The resulting HTML from running Javadoc is shown below
  • Each line above is indented to align with the code below the comment.
  • The first line contains the begin-comment delimiter ( /**).
  • Starting with Javadoc 1.4, the leading asterisks are optional.
  • Write the first sentence as a short summary of the method, as Javadoc automatically places it in the method summary table (and index).
  • Notice the inline tag {@link URL}, which converts to an HTML hyperlink pointing to the documentation for the URL class. This inline tag can be used anywhere that a comment can be written, such as in the text following block tags.
  • If you have more than one paragraph in the doc comment, separate the paragraphs with a <p> paragraph tag, as shown.
  • Insert a blank comment line between the description and the list of tags, as shown.
  • The first line that begins with an "@" character ends the description. There is only one description block per doc comment; you cannot continue the description following block tags.
  • The last line contains the end-comment delimiter ( */) Note that unlike the begin-comment delimiter, the end-comment contains only a single asterisk.
    For more examples, see Simple Examples.

So lines won't wrap, limit any doc-comment lines to 80 characters.

Guidelines

Status Guideline Check Coverage Notes
🟢 Covered Each line of the comment is indented to align with the code below the comment CommentsIndentation
JavadocLeadingAsteriskAlign
This is enforced through a combination of checks. CommentsIndentation ensures that the Javadoc comment block is aligned with the surrounding code, while JavadocLeadingAsteriskAlign enforces alignment of the leading * on each line. Together, the two checks cover both aspects of the guideline.
🟢 Covered Empty line between the description and the list of tags RequireEmptyLineBeforeBlockTagGroup RequireEmptyLineBeforeBlockTagGroup enforces the presence of a blank line before the block tag section.
🟢 Covered There is only one description block per doc comment; you cannot continue the description following block tags JavadocTagContinuationIndentation JavadocTagContinuationIndentation enforces the indentation of continuation lines in Javadoc block tags. This matches the Javadoc tool behaviour: once the block tag section begins, later text is treated as part of the corresponding block tag description, not as a new free-standing description block. Therefore, text placed after block tags is handled as tag continuation text and must follow the expected continuation indentation.
🔴 Missing The last line contains the end-comment delimiter (*/) Note that unlike the begin-comment delimiter, the end-comment contains only a single asterisk Missing There is currently no check ensuring that the closing delimiter uses exactly one asterisk. As a result, invalid forms such as **/ may be accepted.
🟢 Covered Limit any doc-comment lines to 80 characters LineLength This can be enforced with LineLength by setting max to 80 and using ignorePattern to ignore lines that do not look like Javadoc comment lines. For example: <property name="ignorePattern" value="^(?!\s*\*).*$"/>. This checks lines starting with *, while ignoring ordinary code lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions