summaryrefslogtreecommitdiff
path: root/src/partest/scala/tools/partest/ScaladocModelTest.scala
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2012-07-12 00:31:25 +0200
committerVlad Ureche <vlad.ureche@gmail.com>2012-07-16 23:41:44 +0200
commitdc70d1b7bd193ff42e9bed5d80f632cffb85a667 (patch)
treeed8cd8eff307a6d817e2c65829f06b2cb66d8080 /src/partest/scala/tools/partest/ScaladocModelTest.scala
parent929415a3f4d5d6261d10cc6d28720c5241716bae (diff)
downloadscala-dc70d1b7bd193ff42e9bed5d80f632cffb85a667.tar.gz
scala-dc70d1b7bd193ff42e9bed5d80f632cffb85a667.tar.bz2
scala-dc70d1b7bd193ff42e9bed5d80f632cffb85a667.zip
SI-3695 SI-4224 SI-4497 SI-5079 scaladoc links
Adds the ability to link to members, classes and objects in scaladoc. The links can now be either qualified names or relative names, they both work. See the test/scaladoc/resources/links.scala for a usage example. Also introduced -no-link-warnings scaladoc flag, in case the build output gets swamped with link warnings.
Diffstat (limited to 'src/partest/scala/tools/partest/ScaladocModelTest.scala')
-rw-r--r--src/partest/scala/tools/partest/ScaladocModelTest.scala13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/partest/scala/tools/partest/ScaladocModelTest.scala b/src/partest/scala/tools/partest/ScaladocModelTest.scala
index c89dd2cb8f..fb93e98726 100644
--- a/src/partest/scala/tools/partest/ScaladocModelTest.scala
+++ b/src/partest/scala/tools/partest/ScaladocModelTest.scala
@@ -12,7 +12,7 @@ import scala.tools.nsc.util.CommandLineParser
import scala.tools.nsc.doc.{Settings, DocFactory, Universe}
import scala.tools.nsc.doc.model._
import scala.tools.nsc.reporters.ConsoleReporter
-import scala.tools.nsc.doc.model.comment.Comment
+import scala.tools.nsc.doc.model.comment._
/** A class for testing scaladoc model generation
* - you need to specify the code in the `code` method
@@ -165,10 +165,21 @@ abstract class ScaladocModelTest extends DirectTest {
def extractCommentText(c: Comment) = {
def extractText(body: Any): String = body match {
case s: String => s
+ case s: Seq[_] => s.toList.map(extractText(_)).mkString
case p: Product => p.productIterator.toList.map(extractText(_)).mkString
case _ => ""
}
extractText(c.body)
}
+
+ def countLinks(c: Comment, p: EntityLink => Boolean) = {
+ def countLinks(body: Any): Int = body match {
+ case el: EntityLink if p(el) => 1
+ case s: Seq[_] => s.toList.map(countLinks(_)).sum
+ case p: Product => p.productIterator.toList.map(countLinks(_)).sum
+ case _ => 0
+ }
+ countLinks(c.body)
+ }
}
}