How do I link variables inside another object in scaladocs?

倾然丶 夕夏残阳落幕 提交于 2021-01-20 04:28:05

问题


To link another class, I can use [[package.Classname]]. Linking functions defined by def works as well, but trying to link variables doesn't work.

What I've tried:

object Foo {

  val BAR = 0
}

object Example {

  /**
  * Does the thing with [[Foo.BAR]]
  */
  def doTheThing(): Unit = {

  }
}

I've also tried [[Foo#BAR]] (from another post) instead of [[Foo.BAR]], which fails as well.

What's the proper way to link variables in scaladoc?


回答1:


The right way to go is what you have already tried:

/**
* Does the thing with [[Foo.BAR]]
*/

Please note that if this is just an example to a more complicated scenario, you need to include the whole package path of Foo.BAR. For example, if Foo is under:

package a.b.c.d

Then you need to do:

/**
* Does the thing with [[a.b.c.d.Foo.BAR]]
*/

You can find in the scaladocs docs:

Create links to referenced Scala Library classes using the square-bracket syntax, e.g. [[scala.Option]]

For more information you can read SCALADOC FOR LIBRARY AUTHORS

You can see here and example how the akka library is using it.



来源:https://stackoverflow.com/questions/64584331/how-do-i-link-variables-inside-another-object-in-scaladocs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!