-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
From: 7.1.1 General Form and google/google-java-format#1279 (comment)
7.1.1 General form
The basic formatting of Javadoc blocks is as seen in this example:
/**
* Multiple lines of Javadoc text are written here,
* wrapped normally...
*/
public int method(String p1) { ... }
... or in this single-line example:
/** An especially short bit of Javadoc. */
The basic form is always acceptable. The single-line form may be substituted when the entirety of the Javadoc block (including comment markers) can fit on a single line.
Part of 17778, subproblem 3
According to Google Java Style, the preferred form is to place /** and */ on their own lines unless the entire Javadoc comment fits on a single line. However, in google_checks.xml, the JavadocLeadingAsteriskAlign check validates the alignment of the closing asterisk only when whitespace appears before the */. It ignore the alignment of leading asterisk when non-whitespace characters appear before the */. The following example is:
/**
* Correct Indentation for leading asterisk. */
private void foo2() {}
If we can add support for validating the alignment of the closing */, it would improve compliance with the Google Javadoc style.
Google Formatter
Test.java
public class Test {
/**
* void constructor.
*
* @param a testing... */
public Test(int a) {}
}
cli:
$ java -jar google-java-format-1.33.0-all-deps.jar Test.java > FormattedCode.java
Formatted Code:
public class Test {
/**
* void constructor.
*
* @param a testing...
*/
public Test(int a) {}
}
Cli:
$ diff -Naru Test.java FormattedCode.java
--- Test.java 2025-12-12 00:50:02.874673400 +0530
+++ FormattedCode.java 2025-12-12 00:51:12.628082900 +0530
@@ -1,9 +1,9 @@
public class Test {
-
+
/**
* void constructor.
*
- * @param a testing... */
+ * @param a testing...
+ */
public Test(int a) {}
-
}