gpt4 book ai didi

scala - 无法为重载方法创建 ScalaDoc 链接

转载 作者:行者123 更新时间:2023-12-04 08:34:59 24 4
gpt4 key购买 nike

我在使用重载时遇到了 ScalaDoc 不接受方法链接的问题。

一个独立的例子:文件 project/build.properties :

sbt.version=0.13.2

文件 build.sbt :
scalaVersion := "2.11.0"

文件 src/main/scala/Foo.scala :
package foobar

/** @see [[Bar#foo]]
* @see [[Bar#bar]]
*/
case class Foo()

abstract class Bar {
def foo: Int

def bar: Foo
def bar(x: Option[Int]): Foo
}

当我跑 sbt doc , [[Bar#foo]]链接很好,但 [[Bar#bar]]不接受链接:
[warn] .../src/main/scala/Foo.scala:3: The link target "Bar#bar" is ambiguous. 
Several members fit the target:
[warn] (x: Option[Int]): foobar.Foo in class Bar [chosen]
[warn] : foobar.Foo in class Bar
[warn]
[warn]
[warn] Quick crash course on using Scaladoc links
[warn] ==========================================
[warn] Disambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use:
[warn] - [[scala.collection.immutable.List!.apply class List's apply method]] and
[warn] - [[scala.collection.immutable.List$.apply object List's apply method]]
[warn] Disambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *:
[warn] - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]]
[warn] - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]]
[warn] Notes:
[warn] - you can use any number of matching square brackets to avoid interference with the signature
[warn] - you can use \\. to escape dots in prefixes (don't forget to use * at the end to match the signature!)
[warn] - you can use \\# to escape hashes, otherwise they will be considered as delimiters, like dots.
[warn] /** @see [[Bar#foo]]
[warn] ^
[warn] one warning found

因此,使用“速成类(class)”,我尝试了各种方法,例如
[[Bar#bar:Foo*]]
[[Bar!.bar:Foo*]]
[[foobar.Bar!.bar:foobar.Foo*]]

这些都不起作用。既不使用其他重载变体:
[[Bar#bar(Option[Int])]]
[[Bar#bar(Option[Int]):Foo]]
[[Bar!.bar(Option[Int]):Foo*]]

所以要么(像往常一样......)scala-doc完全坏了,或者我做错了什么?

最佳答案

以下对我有用。使用完全限定的参数和返回类型,其中点以 \ 为前缀。 .

[[Bar#bar:foobar\.Foo* The first bar method without argument]]
[[Bar#bar(x:Option[Int]):foobar\.Foo* The second bar method with argument]]

关于scala - 无法为重载方法创建 ScalaDoc 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23181672/

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