kotlin - 用 KDoc 注释变量的正确方法是什么?
问题描述
我试图像@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) {
// ...
}
推荐阅读
- r - 如何使用 n 对日期(键)/值列自动整理数据框
- reactjs - Context Provider 的值不会改变
- linux - &符号没有将进程置于后台
- django - DRF 中 ModelSerializer 中的创建和更新方法中的重复代码
- asp.net-core - 在 ASP.NET Core 运行时扩展 Autofac IoC 容器配置
- html - 尝试并未能使用 HTML 和 Bootstrap 并排呈现两个表格
- javascript - 如何从 Vue 路由器访问 Vuex getter
- python - 使用 Python 更新 DynamoDB 中的项目的项目结构缺失
- reactjs - 不明白为什么我不能访问计数器的值
- android - Kotlin 可以一个片段触发一个活动的 onNewIntent