summaryrefslogtreecommitdiff
path: root/test/scaladoc
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2012-07-08 23:57:56 +0200
committerVlad Ureche <vlad.ureche@gmail.com>2012-07-16 23:41:44 +0200
commit929415a3f4d5d6261d10cc6d28720c5241716bae (patch)
tree5d3f3e66415e63901730f1d2981a68cadb451436 /test/scaladoc
parent8d0ea747c240e4881c057a78cf2c90e69369ca4b (diff)
downloadscala-929415a3f4d5d6261d10cc6d28720c5241716bae.tar.gz
scala-929415a3f4d5d6261d10cc6d28720c5241716bae.tar.bz2
scala-929415a3f4d5d6261d10cc6d28720c5241716bae.zip
SI-4887 Link existentials in scaladoc
Based on an inital patch by Nada Amin. Rewrote some of the code to compress it a bit. Also fixed a problem that was affecting the prefix printing for typerefs: type parameter and existentials won't get prefixes. While I can imagine cases where you'd want to see where they come from, you can always hover over them and see their origin. Also added support for pretty-printing ThisTypes, SuperTypes and SingleTypes (with links)
Diffstat (limited to 'test/scaladoc')
-rw-r--r--test/scaladoc/resources/SI-3314.scala15
-rw-r--r--test/scaladoc/run/SI-3314.scala19
-rw-r--r--test/scaladoc/run/SI-4887.check1
-rw-r--r--test/scaladoc/run/SI-4887.scala46
4 files changed, 80 insertions, 1 deletions
diff --git a/test/scaladoc/resources/SI-3314.scala b/test/scaladoc/resources/SI-3314.scala
index e5773a4970..9e0afdce9d 100644
--- a/test/scaladoc/resources/SI-3314.scala
+++ b/test/scaladoc/resources/SI-3314.scala
@@ -1,5 +1,6 @@
package scala.test.scaladoc {
+ // testing inherited <documented> templates (Enum.Value is included in the source, thus is documented in scaladoc)
package test1 {
class Enum {
abstract class Value
@@ -12,6 +13,8 @@ package scala.test.scaladoc {
}
}
+ // testing inherited <not documented> templates (scala.Enumeration.Value is taken from the library, thus is not
+ // documented in the scaladoc pages -- but should be inherited to make things clear!)
package test2 {
trait WeekDayTrait extends Enumeration {
type WeekDay = Value
@@ -67,4 +70,16 @@ package scala.test.scaladoc {
def isWorkingDay9(d: WeekDayObject.Value) = ! (d == Sat || d == Sun)
}
}
+
+ // testing type lambdas and useless prefixes (should be referenced as T instead of foo.T in the first example)
+ package test3 {
+ import language.higherKinds
+ object `package` {
+ trait T
+ trait A
+ trait X
+ def foo[T](x: T) = 7
+ def bar[A](x: ({type Lambda[X] <: Either[A, X]})#Lambda[String]) = 5
+ }
+ }
}
diff --git a/test/scaladoc/run/SI-3314.scala b/test/scaladoc/run/SI-3314.scala
index 3b5c658078..fe220b08af 100644
--- a/test/scaladoc/run/SI-3314.scala
+++ b/test/scaladoc/run/SI-3314.scala
@@ -6,7 +6,7 @@ object Test extends ScaladocModelTest {
override def resourceFile = "SI-3314.scala"
// no need for special settings
- def scaladocSettings = ""
+ def scaladocSettings = "-feature"
def testModel(rootPackage: Package) = {
// get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
@@ -15,6 +15,10 @@ object Test extends ScaladocModelTest {
// just need to check the member exists, access methods will throw an error if there's a problem
val base = rootPackage._package("scala")._package("test")._package("scaladoc")
+
+
+ // test1
+
val test1 = base._package("test1")
val test1Value = test1._class("Enum")._method("Value").resultType
assert(test1Value.name == "Value", test1Value.name + " == Value")
@@ -26,6 +30,9 @@ object Test extends ScaladocModelTest {
assert(test1Constants.refEntity(0)._1 == LinkToMember(test1._object("Constants")._class("Value"), test1._object("Constants")),
test1Constants.refEntity(0)._1 + " == LinkToMember(test1.Enum.Value)")
+
+ // test2
+
val test2 = base._package("test2")
def testDefinition(doc: DocTemplateEntity) = {
for (day <- List("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")) {
@@ -70,5 +77,15 @@ object Test extends ScaladocModelTest {
testUsage(test2._object("UserObject"))
testUsage(test2._class("UserClass"))
testUsage(test2._trait("UserTrait"))
+
+
+ // test3
+ val test3 = base._package("test3")
+ val foo = test3._method("foo")
+ assert(foo.valueParams(0)(0).resultType.name == "T",
+ foo.valueParams(0)(0).resultType.name + " == T")
+ val bar = test3._method("bar")
+ assert(bar.valueParams(0)(0).resultType.name == "(AnyRef { type Lambda[X] <: Either[A,X] })#Lambda[String]",
+ bar.valueParams(0)(0).resultType.name + " == (AnyRef { type Lambda[X] <: Either[A,X] })#Lambda[String]")
}
} \ No newline at end of file
diff --git a/test/scaladoc/run/SI-4887.check b/test/scaladoc/run/SI-4887.check
new file mode 100644
index 0000000000..619c56180b
--- /dev/null
+++ b/test/scaladoc/run/SI-4887.check
@@ -0,0 +1 @@
+Done.
diff --git a/test/scaladoc/run/SI-4887.scala b/test/scaladoc/run/SI-4887.scala
new file mode 100644
index 0000000000..af83344613
--- /dev/null
+++ b/test/scaladoc/run/SI-4887.scala
@@ -0,0 +1,46 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ override def code = """
+ package scala.test.scaladoc.existentials {
+ import language.higherKinds
+ import language.existentials
+
+ class X[T, U, V]
+
+ trait TEST {
+ type T
+ type U
+ type A
+ def foo1(x: X[T, U, _]) = 3
+ def foo2(x: X[Z[_], U, z.type] forSome {type Z[_] <: { def z: String }; val z: Z[_ <: Int]}) = 4
+ def foo3(x: X[Z, Z, V] forSome { type Z <: T; type V <: T }) = 6
+ }
+ }
+ """
+
+ // no need for special settings
+ def scaladocSettings = "-feature"
+
+ def testModel(rootPackage: Package) = {
+ // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
+ import access._
+
+ val base = rootPackage._package("scala")._package("test")._package("scaladoc")._package("existentials")
+ val TEST = base._trait("TEST")
+
+ val foo1 = TEST._method("foo1")
+ assert(foo1.valueParams(0)(0).resultType.name == "X[T, U, _]",
+ foo1.valueParams(0)(0).resultType.name + " == X[T, U, _]")
+
+ val foo2 = TEST._method("foo2")
+ assert(foo2.valueParams(0)(0).resultType.name == "X[Z[_], U, _ <: [_]AnyRef { def z: String } with Singleton]",
+ foo2.valueParams(0)(0).resultType.name + " == X[Z[_], U, _ <: [_]AnyRef { def z: String } with Singleton]")
+
+ val foo3 = TEST._method("foo3")
+ assert(foo3.valueParams(0)(0).resultType.name == "X[Z, Z, V] forSome {type Z <: T, type V <: T}",
+ foo3.valueParams(0)(0).resultType.name + " == X[Z, Z, V] forSome {type Z <: T, type V <: T}")
+ }
+} \ No newline at end of file