'Line break, new line in KDoc
Assuming we have such documented string
/** retrieve a state of the service
* <br/> HTTP code 200 - normal state
* <br/> HTTP code 403 - some recoverable state:
const val SERVICE_STATE = "servicestate" */
There are several <br/> here, which i used to break a line, like i do in java, but output of AndroidStudio (seems same in InteliJIdea) is
with java it is parsed & displayed correctly:
/** retrieve a state of the service
* <br/> HTTP code 200 - normal state
* <br/> HTTP code 403 - some recoverable state */
public static final String SERVICE_STATE = "servicestate";
Can i somehow achieve the same with kotlin & IntelijIdea, maybe kotlin has another option to break the line in KDoc?
Solution 1:[1]
The KDoc format uses Markdown syntax instead of HTML, and basic Markdown does not provide a way to break the line without starting a new paragraph.
I'm not sure why the Kotlin IntellIJ plugin does not support <br/> or the double space hack.
If starting a new paragraph is OK, just skip an empty line:
/**
* retrieve a state of the service
*
* HTTP code 200 - normal state
*
* HTTP code 403 - some recoverable state:
*/
The result is:
Solution 2:[2]
To add to @hotkey's answer, you can also use triple backticks as Markdown is supported:
/**
* Returns masked complement, i.e. expected value in the [maskBits] bits instead of a negative number because of
* 2's complement representation
*
* For example, for 9:
* ```
* Binary representation: 00...01001
* Complement: 11...10110 which is -10
* Masking with 4 bits: and with 00...01111
* So we get: 00...00110 which is the expected bitwise complement
* ```
* @param maskBits Number of bits to mask the complement to
* @return Decimal representation of the masked complement
*/
fun Int.inv(maskBits: Int) = inv() and 2.pow(maskBits) - 1
The result is:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |



