I'm documenting a Scala class with overloaded methods. How can I distinguish them when referring to them in scaladoc comments? For example, if I have
/**
* 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;
}
and run sbt doc
I get
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
Using foo[A,B >: A]
etc. to the link doesn't work.
The following seems do the trick in Scala 2.10.
And here is some hint scaladoc gives me:
I found a solution (apparently the unique solution) for complex signatures, by studying the doc of scaladoc.
\
*
at the end of the signature*
Example:
I'm still surprised at how difficult it is to get this working and the lack of documentation for scaladoc itself. I decided to search the scala code base itself in hope of some useful examples. The best ones that I found were in https://github.com/scala/scala/blob/2.12.x/test/scaladoc/resources/links.scala. Hopefully this is useful for someone else who comes across this.