31

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 enter image description here

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";

enter image description here

Can i somehow achieve the same with kotlin & IntelijIdea, maybe kotlin has another option to break the line in KDoc?

Beloo
  • 9,723
  • 7
  • 40
  • 71

3 Answers3

36

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:

enter image description here

TWiStErRob
  • 44,762
  • 26
  • 170
  • 254
hotkey
  • 140,743
  • 39
  • 371
  • 326
9

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:

enter image description here

aksh1618
  • 2,245
  • 18
  • 37
2

It is possible to use dashes in lists. Empty lines are not needed in this case.

enter image description here

macros013
  • 739
  • 9
  • 10