gpt4 book ai didi

scala - 如何在 Scala 文档中链接另一个对象内的变量?

转载 作者:行者123 更新时间:2023-12-03 16:32:23 25 4
gpt4 key购买 nike

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

object Foo {

val BAR = 0
}

object Example {

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

}
}
我也试过 [[Foo#BAR]] (来自另一个 post )而不是 [[Foo.BAR]] ,这也失败了。
在 Scaladoc 中链接变量的正确方法是什么?

最佳答案

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

/**
* Does the thing with [[Foo.BAR]]
*/
请注意,如果这只是一个更复杂场景的示例,您需要包含 Foo.BAR的整个包路径。 .例如,如果 Foo在下面:
package a.b.c.d
然后你需要做:
/**
* Does the thing with [[a.b.c.d.Foo.BAR]]
*/
您可以在 Scaladocs docs 中找到:

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


欲了解更多信息,您可以阅读 SCALADOC FOR LIBRARY AUTHORS
你可以看到 here并举例说明 akka图书馆正在使用它。

关于scala - 如何在 Scala 文档中链接另一个对象内的变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64584331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com