我试图像@property 一样进行注释,但这是不对的。多卡不认识
例如枚举:
enum class Vegetables(val id: Int) {
POTATO(1),
CARROT(2),
CUCUMBER(3)
}
您可以查看Kotlin 文档,了解如何在代码中添加文档注释。
您可以将文档放置在要记录的任何地方。
/**
* 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)
}
或者,您还可以记录类文档中的属性:
/**
* 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) {
// ...
}