Expected Rule behavior
The rule should check whether Kdoc comment conforms to one of the following rules:
- This Kdoc is a single-line comment that starts with
/** and ends with */.
- This Kdoc is a multi-line comment and
- Kdoc comment starts with the line
/**
- Kdoc comment ends with the line
*/
- all other lines start with
* except the empty lines that should look like * (with no trailing whitespace)
- The number of leading whitespaces is the same for each line, except the first line of the Kdoc comment where the number of whitespaces is one whitespace less than other lines.
The Kotlin coding conventions or Android Style Guide do not strictly define the KDoc comment format, but examples have the same well-readable format.
- https://kotlinlang.org/docs/kotlin-doc.html#kdoc-syntax
- https://developer.android.com/kotlin/style-guide#formatting_2
Examples of good KDoc comments:
/**
* A group of *members*.
*
* This class has no useful logic; it's just a documentation example.
*
* @param T the type of a member in this group.
* @property name the name of this group.
* @constructor Creates an empty group.
*/
/** A group of *members* */
Examples of bad Kdoc comments:
/***
* A group of *members*.
*
* This class has no useful logic; it's just a documentation example.
*
* @param T the type of a member in this group.
* @property name the name of this group.
* @constructor Creates an empty group.
*/
/** A group of *members*.
*
* This class has no useful logic; it's just a documentation example.
*
* @param T the type of a member in this group.
* @property name the name of this group.
* @constructor Creates an empty group.
*/
/**A group of *members* */
Additional information
- Current version of ktlint: 1.5.0
- Styleguide section:
Expected Rule behavior
The rule should check whether Kdoc comment conforms to one of the following rules:
/**and ends with*/./***/*except the empty lines that should look like*(with no trailing whitespace)The Kotlin coding conventions or Android Style Guide do not strictly define the KDoc comment format, but examples have the same well-readable format.
Examples of good KDoc comments:
Examples of bad Kdoc comments:
Additional information