【问题标题】:Documenting Class Properties in Kotlin在 Kotlin 中记录类属性
【发布时间】:2018-09-20 11:21:54
【问题描述】:

自从我从 Java 切换到 Kotlin 后,我不得不重写我的文档。 Kotlin 有自己的文档格式,或者据我所知它扩展了普通的 javadocs。我检查了the official documentation,它声明有一个property 标签,它允许您记录类属性。

如果我的 kdoc 看起来像这样:

/**
 * Tablemodel for the Players of a server, only holds two properties:
 *
 *  * Name
 *  * Score
 *
 * @author marcel
 * @since Jan 10, 2018
 * @property playerName Ingame name of the player
 * @property playerScore Ingame score of the player
 */

这两个属性都不是 IntelliJ 中呈现的 kdoc 的一部分。

如果我移动authorsince 上面的两个属性,它们也不会显示。我不太明白为什么。是 IntelliJ 缺乏适当的 kdoc 支持吗?

【问题讨论】:

  • playerNameplayerScore 是在类中声明 还是作为示例中的参数声明?
  • class Player(var playerName: String, var playerScore: Int) ... 但我想@yole 的答案就足够了,以防它是正确的,我稍后会测试。

标签: java kotlin documentation javadoc


【解决方案1】:

正如 IntelliJ for Java 不会在您对类调用“显示快速文档”操作时显示类的所有字段的 javadocs 一样,IntelliJ for Kotlin 不会将所有属性的文档显示为类快速文档。如果您在属性上调用“显示快速文档”操作,将显示您在 @property 标记中添加的文档。

【讨论】:

    猜你喜欢
    • 2018-09-15
    • 1970-01-01
    • 2011-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 1970-01-01
    相关资源
    最近更新 更多