kotlin - 如何在 Kotlin 中为文档编写注释?
问题描述
我想在不附加到任何特定 Kotlin 类或方法的源代码中添加文档,它就像概念性的高级文档。
我想把它保存在 Kotlin 源文件中,接近它所描述的东西。
理想情况下,我希望能够将其写为:
...
doc(
title = "Some title",
text = "Some text"
)
...
但这是不可能的,因为 Kotlin 不允许顶级调用,我也尝试使用注释,但如果不附加一些东西也是不允许的。
@Doc(
title = "Some title",
text = "Some text"
)
因此,下面的代码有效,但看起来并不好。有更好的吗?
@Doc private val doc1 = doc(
title = "Some title",
text = "Some text"
)
或者可能
@Doc(
title = "Some title",
text = "Some text"
) val tmp = 0
解决方案
推荐阅读
- micronaut - Micronaut 配置注入无法按预期工作
- android - 在 RecyclerView-android 中加载滑行时出现问题
- javascript - 我的 unban 命令有问题 [discord.js v12 slappey]
- python - 递归应用于 Python 中的列表与树
- firebase - Firestore SnapshotListeners 是否有时间限制
- django - DRF 自定义分页无法正常工作
- sql - 如何获取属于该组的某些项目满足条件的组的所有项目?
- javascript - 将excel输入数据拆分为在设定的时间后出现
- lua - 检测到静音时暂停或 JumpCut 视频录制
- date - 反应日期选择器挂起