如何在模式定义中记录val

dav*_*rez 5 scala scaladoc

我想为我班级的每个val和def创建ScalaDoc条目.问题是vals位于模式定义中,并且不知道如何使用/** */语法.

例:

class C(id: String) {
   val (part1, part2) = {
         .....
         (expr1, expr2)
   }
}
Run Code Online (Sandbox Code Playgroud)

我如何记录part1part2

在阅读有关ScalaDoc的文档之前,我已阅读过.

som*_*ytt 3

它应该是

  val (
    /** Part one. */
    x,
    /** Part two. */
    y
  ) = (1, 2)
Run Code Online (Sandbox Code Playgroud)

但对于有缺陷的启发式

/** To prevent doc comments attached to expressions from leaking out of scope
 *  onto the next documentable entity, they are discarded upon passing a right
 *  brace, bracket, or parenthesis.
 */
def discardDocBuffer(): Unit = ()
Run Code Online (Sandbox Code Playgroud)

下面-Xlint你会看到

[warn] /home/apm/goofy/src/main/scala/docked.scala:10: discarding unmoored doc comment
[warn]     /** Part two. */
[warn]     ^
Run Code Online (Sandbox Code Playgroud)

也许可以改进启发式,仅当在封闭实体上没有发现文档时才丢弃。