2014-04-20 3 views
7

Ich stoße auf ein Problem, wenn ScalaDoc keine Methodenverknüpfung akzeptiert, wenn Überladung verwendet wird.ScalaDoc-Link für überladene Methode kann nicht erstellt werden

Ein eigenständiges Beispiel: Die Datei project/build.properties:

sbt.version=0.13.2 

Datei build.sbt:

scalaVersion := "2.11.0" 

Datei 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 
} 

Als ich sbt doc laufen, ist die [[Bar#foo]] Link in Ordnung, aber das [[Bar#bar]] Link nicht akzeptiert wird:

[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 

So den "Crash-Kurs", habe ich mit all möglichen Dingen, zum Beispiel

[[Bar#bar:Foo*]] 
[[Bar!.bar:Foo*]] 
[[foobar.Bar!.bar:foobar.Foo*]] 

Nichts davon funktioniert. Weder mit der anderen überladenen Variante:

[[Bar#bar(Option[Int])]] 
[[Bar#bar(Option[Int]):Foo]] 
[[Bar!.bar(Option[Int]):Foo*]] 

Also entweder (wie immer ...) scala-doc ist total kaputt, oder ich tue etwas falsch gemacht?

Antwort

3

Folgendes funktionierte für mich. Verwenden Sie vollständig qualifizierte Argument- und Rückgabetypen, wobei Punkten \ vorangestellt wurde.

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

Ich versuchte es mit:

package foobar 

/** @see [[Bar#foo]] 
    * @see [[Bar!.bar*]] 
    * @see [[[Bar!.bar(x:Option[Int])*]]] 
    */ 
case class Foo() 

abstract class Bar { 
    def foo: Int 

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

Und obwohl ich die gleiche Warnung erhalten, werden die Dokumente mit Links zu den beiden bar Methoden erzeugt.

Also ich denke, Scala-Doc ist nicht total gebrochen ... nur ein wenig nervig.

Verwandte Themen