gpt4 book ai didi

scala - 如何消除scaladoc中方法链接的歧义?

转载 作者:行者123 更新时间:2023-12-03 09:08:05 25 4
gpt4 key购买 nike

我正在用 overloaded methods 记录一个 Scala 类.在 Scaladoc 注释中提及它们时如何区分它们?例如,如果我有

/**
* The most important method is [[Doc.foo]].
*/
object Doc {
def foo[A]: A = throw new UnsupportedOperationException;
def foo[A,B >: A](x: A): B = x;
}

并运行 sbt doc我得到

Doc.scala:1: warning: The link target "Doc.foo" is ambiguous. Several (possibly overloaded) members fit the target:

  • method foo[A,B>:A](x:A):B in object Doc [chosen]
  • method foo[A]:Nothing in object Doc


使用 foo[A,B >: A]等链接不起作用。

最佳答案

以下似乎在 Scala 2.10 中起作用。

/**
* The most important method is [[Doc.foo[A]:A*]].
*/

这是 Scaladoc 给我的一些提示:
[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.

关于scala - 如何消除scaladoc中方法链接的歧义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15394322/

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