如何在 scaladocs 中的另一个对象内链接变量? [英] How do I link variables inside another object in scaladocs?

查看:35
本文介绍了如何在 scaladocs 中的另一个对象内链接变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要链接另一个类,我可以使用[[package.Classname]].def 定义的链接函数也可以,但是尝试链接变量不起作用.

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.

我尝试过的:

object Foo {

  val BAR = 0
}

object Example {

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

  }
}

我也试过 [[Foo#BAR]](来自另一个 post) 而不是 [[Foo.BAR]],后者也会失败.

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

在 scaladoc 中链接变量的正确方法是什么?

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

推荐答案

正确的方法是你已经尝试过的:

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

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

请注意,如果这只是一个更复杂场景的示例,您需要包含Foo.BAR的整个包路径.例如,如果 Foo 在:

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

那么你需要这样做:

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

您可以在 scaladocs docs 中找到:

You can find in the scaladocs docs:

使用方括号语法创建指向引用的 Scala 库类的链接,例如[[scala.Option]]

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

有关更多信息,您可以阅读SCALADOC FOR LIBRARY AUTHORS

For more information you can read SCALADOC FOR LIBRARY AUTHORS

可以看到此处 以及 akka 库如何使用它的示例.

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

这篇关于如何在 scaladocs 中的另一个对象内链接变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆