使用 KDoc 注释变量的正确方法是什么?
What is the proper way to annotate variable with KDoc?
我试过像@属性这样的注释,但这是不对的。 Dokka不承认
例如枚举:
enum class Vegetables(val id: Int) {
POTATO(1),
CARROT(2),
CUCUMBER(3)
}
您可以查看 Kotlin documentation 关于如何在代码中放置文档注释的内容。
您可以将文档放在任何您想要记录的地方。
/**
* Here goes your main Vegetables type doc.
*
* You can refer to the [id] constructor argument like this.
*/
enum class Vegetables(
/**
* Here goes the doc for your id constructor argument and property.
*/
val id: Int
) {
/**
* Here goes the doc for POTATO.
*/
POTATO(1),
/**
* Here goes the doc for CARROT.
*/
CARROT(2),
/**
* Here goes the doc for CUCUMBER.
*/
CUCUMBER(3)
}
或者,您也可以从 class 文档中记录属性:
/**
* Here goes your main Vegetables type doc.
*
* You can refer to the [id] constructor argument like this.
*
* @property id You can also document the id property this way
*/
enum class Vegetables(val id: Int) {
// ...
}
我试过像@属性这样的注释,但这是不对的。 Dokka不承认
例如枚举:
enum class Vegetables(val id: Int) {
POTATO(1),
CARROT(2),
CUCUMBER(3)
}
您可以查看 Kotlin documentation 关于如何在代码中放置文档注释的内容。
您可以将文档放在任何您想要记录的地方。
/**
* Here goes your main Vegetables type doc.
*
* You can refer to the [id] constructor argument like this.
*/
enum class Vegetables(
/**
* Here goes the doc for your id constructor argument and property.
*/
val id: Int
) {
/**
* Here goes the doc for POTATO.
*/
POTATO(1),
/**
* Here goes the doc for CARROT.
*/
CARROT(2),
/**
* Here goes the doc for CUCUMBER.
*/
CUCUMBER(3)
}
或者,您也可以从 class 文档中记录属性:
/**
* Here goes your main Vegetables type doc.
*
* You can refer to the [id] constructor argument like this.
*
* @property id You can also document the id property this way
*/
enum class Vegetables(val id: Int) {
// ...
}