Kotlin's documentation syntax is called KDoc. A KDoc block is placed above the construct it describes, and begins with
/** and ends with
*/ (possibly on one line; if not, each intermediate lines should start with an aligned asterisk). The first block of text is the summary; then, you can use block tags to provide information about specific parts of the construct. Some block tags are
@param for function parameters and generic type parameters, and
@return for the return value. You can link to identifiers inside brackets. All the text outside of links and block tag names is in Markdown format.
/** * Squares a number. * * @param number Any [Double] number whose absolute value is * less than or equal to the square root of [Double.MAX_VALUE]. * @return A nonnegative number: the result of multiplying [number] with itself. */ fun square(number: Double) = number * number
Package-level documentation can be provided in a separate Markdown file.
Unlike docstrings, KDoc blocks are not available to the program at runtime.
You can generate separate documentation files in HTML format from KDoc by using a tool called Dokka.