换行,KDoc的新行

Bel*_*loo 9 intellij-idea kotlin android-studio kdoc

假设我们有这样的文件字符串

/** retrieve a state of the service
* <br/> HTTP code 200 - normal state
* <br/> HTTP code 403 - some recoverable state:
const val SERVICE_STATE = "servicestate" */
Run Code Online (Sandbox Code Playgroud)

这里有几个<br/>,我用来打破一条线,就像我在java中做的那样,但AndroidStudio的输出(在InteliJIdea中看起来相同)是 在此输入图像描述

使用java,它被正确解析和显示:

/** 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";
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我能以某种方式与kotlin和IntelijIdea达到同样的目的,也许kotlin可以在KDoc中打破这条线吗?

hot*_*key 13

KDoc格式使用Markdown语法而不是HTML,并且基本Markdown不提供在不启动新段落的情况下断行的方法.

我不确定为什么Kotlin IntellIJ插件不支持<br/>双空间黑客攻击.

如果开始一个新的段落是好的,只需跳过一个空行:

/** 
 * retrieve a state of the service
 *
 * HTTP code 200 - normal state
 *
 * HTTP code 403 - some recoverable state:
 */
Run Code Online (Sandbox Code Playgroud)

结果是:

在此输入图像描述

  • 在两个代码行之间留一个空行怎么样?我找不到它。 (3认同)

aks*_*618 11

要添加到@hotkey 的答案,您还可以使用三个反引号,因为支持 Markdown:

/**
 * 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

Run Code Online (Sandbox Code Playgroud)

结果是:

在此输入图像描述