summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-05 22:38:20 -0800
committerPaul Phillips <paulp@improving.org>2012-02-05 22:38:20 -0800
commit5be13bf0e0a2df0ddeda7652db0f54c0cba6c3bf (patch)
tree60e8b478d7f8eda0a407d1a4668de6a14ed22e83
parent9d00ea8d389f4426f1f644e0a7f48e9ea380e9fc (diff)
downloadscala-5be13bf0e0a2df0ddeda7652db0f54c0cba6c3bf.tar.gz
scala-5be13bf0e0a2df0ddeda7652db0f54c0cba6c3bf.tar.bz2
scala-5be13bf0e0a2df0ddeda7652db0f54c0cba6c3bf.zip
Revert "Scaladoc @usecase annotation overriding / SI-5287"
This reverts commit 7946ac410ad74894cd0eb6dfd29447f173911b99.
-rwxr-xr-xsrc/compiler/scala/tools/nsc/util/DocStrings.scala26
-rw-r--r--test/scaladoc/resources/implicit-inheritance-override.scala41
-rw-r--r--test/scaladoc/resources/implicit-inheritance-usecase.scala57
-rw-r--r--test/scaladoc/scala/html/HtmlFactoryTest.scala189
4 files changed, 36 insertions, 277 deletions
diff --git a/src/compiler/scala/tools/nsc/util/DocStrings.scala b/src/compiler/scala/tools/nsc/util/DocStrings.scala
index 2c8b77be71..1db6c38b4d 100755
--- a/src/compiler/scala/tools/nsc/util/DocStrings.scala
+++ b/src/compiler/scala/tools/nsc/util/DocStrings.scala
@@ -71,35 +71,13 @@ object DocStrings {
* Every section starts with a `@` and extends to the next `@`, or
* to the end of the comment string, but excluding the final two
* characters which terminate the comment.
- *
- * Also take usecases into account - they need to expand until the next
- * @usecase or the end of the string, as they might include other sections
- * of their own
*/
def tagIndex(str: String, p: Int => Boolean = (idx => true)): List[(Int, Int)] =
findAll(str, 0) (idx => str(idx) == '@' && p(idx)) match {
case List() => List()
- case idxs => {
- val idxs2 = mergeUsecaseSections(str, idxs)
- idxs2 zip (idxs2.tail ::: List(str.length - 2))
- }
- }
-
- /**
- * Merge sections following an @usecase into the usecase comment, so they
- * can override the parent symbol's sections
- */
- def mergeUsecaseSections(str: String, idxs: List[Int]): List[Int] = {
- idxs.find(str.substring(_).startsWith("@usecase")) match {
- case Some(firstUC) =>
- val commentSections = idxs.take(idxs.indexOf(firstUC))
- val usecaseSections = idxs.drop(idxs.indexOf(firstUC)).filter(str.substring(_).startsWith("@usecase"))
- commentSections ::: usecaseSections
- case None =>
- idxs
+ case idxs => idxs zip (idxs.tail ::: List(str.length - 2))
}
- }
-
+
/** Does interval `iv` start with given `tag`?
*/
def startsWithTag(str: String, section: (Int, Int), tag: String): Boolean =
diff --git a/test/scaladoc/resources/implicit-inheritance-override.scala b/test/scaladoc/resources/implicit-inheritance-override.scala
deleted file mode 100644
index 85b8e8d543..0000000000
--- a/test/scaladoc/resources/implicit-inheritance-override.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-// This tests the implicit comment inheritance capabilities of scaladoc for class inheritance (no $super, no @inheritdoc)
-class Base {
- /**
- * The base comment. And another sentence...
- *
- * @param arg1 The T term comment
- * @param arg2 The string comment
- * @tparam T the type of the first argument
- * @return The return comment
- */
- def function[T](arg1: T, arg2: String): Double = 0.0d
-}
-
-class DerivedA extends Base {
- /**
- * Overriding the comment, the params and returns comments should stay the same.
- */
- override def function[T](arg1: T, arg2: String): Double = 1.0d
-}
-
-class DerivedB extends Base {
- /**
- * @param arg1 The overridden T term comment
- * @param arg2 The overridden string comment
- */
- override def function[T](arg1: T, arg2: String): Double = 2.0d
-}
-
-class DerivedC extends Base {
- /**
- * @return The overridden return comment
- */
- override def function[T](arg1: T, arg2: String): Double = 3.0d
-}
-
-class DerivedD extends Base {
- /**
- * @tparam T The overriden type parameter comment
- */
- override def function[T](arg1: T, arg2: String): Double = 3.0d
-} \ No newline at end of file
diff --git a/test/scaladoc/resources/implicit-inheritance-usecase.scala b/test/scaladoc/resources/implicit-inheritance-usecase.scala
deleted file mode 100644
index 8dd1262e4b..0000000000
--- a/test/scaladoc/resources/implicit-inheritance-usecase.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-// This tests the implicit comment inheritance capabilities of scaladoc for usecases (no $super, no @inheritdoc)
-/** Testing use case inheritance */
-class UseCaseInheritance {
- /**
- * The base comment. And another sentence...
- *
- * @param arg1 The T term comment
- * @param arg2 The string comment
- * @tparam T The type parameter
- * @return The return comment
- *
- * @usecase def missing_arg[T](arg1: T): Double
- *
- * @usecase def missing_targ(arg1: Int, arg2: String): Double
- *
- * @usecase def overridden_arg1[T](implicit arg1: T, arg2: String): Double
- * @param arg1 The overridden T term comment
- *
- * @usecase def overridden_targ[T](implicit arg1: T, arg2: String): Double
- * @tparam T The overridden type parameter comment
- *
- * @usecase def overridden_return[T](implicit arg1: T, arg2: String): Double
- * @return The overridden return comment
- *
- * @usecase def added_arg[T](implicit arg1: T, arg2: String, arg3: Float): Double
- * @param arg3 The added float comment
- *
- * @usecase def overridden_comment[T](implicit arg1: T, arg2: String): Double
- * The overridden comment.
- */
- def function[T](implicit arg1: T, arg2: String): Double = 0.0d
-}
-
-/** Testing the override-use case interaction */
-class UseCaseOverrideInheritance extends UseCaseInheritance {
- /**
- * @usecase def missing_arg[T](arg1: T): Double
- *
- * @usecase def missing_targ(arg1: Int, arg2: String): Double
- *
- * @usecase def overridden_arg1[T](implicit arg1: T, arg2: String): Double
- * @param arg1 The overridden T term comment
- *
- * @usecase def overridden_targ[T](implicit arg1: T, arg2: String): Double
- * @tparam T The overridden type parameter comment
- *
- * @usecase def overridden_return[T](implicit arg1: T, arg2: String): Double
- * @return The overridden return comment
- *
- * @usecase def added_arg[T](implicit arg1: T, arg2: String, arg3: Float): Double
- * @param arg3 The added float comment
- *
- * @usecase def overridden_comment[T](implicit arg1: T, arg2: String): Double
- * The overridden comment.
- */
- override def function[T](implicit arg1: T, arg2: String): Double = 0.0d
-}
diff --git a/test/scaladoc/scala/html/HtmlFactoryTest.scala b/test/scaladoc/scala/html/HtmlFactoryTest.scala
index 37aa302ac7..e2687dd510 100644
--- a/test/scaladoc/scala/html/HtmlFactoryTest.scala
+++ b/test/scaladoc/scala/html/HtmlFactoryTest.scala
@@ -84,7 +84,12 @@ object Test extends Properties("HtmlFactory") {
val html = scala.stripSuffix(".scala") + ".html"
createTemplates(scala)(html)
}
-
+
+ /**
+ * See checkTextOnly(scalaFile: String, checks: List[String])
+ */
+ def checkText1(scalaFile: String, check: String, debug: Boolean = true): Boolean = checkText(scalaFile, List(check), debug)
+
/**
* This tests the text without the markup - ex:
*
@@ -106,31 +111,20 @@ object Test extends Properties("HtmlFactory") {
*
* NOTE: Comparison is done ignoring all whitespace
*/
- def checkText(scalaFile: String, debug: Boolean = true)(checks: (Option[String], String, Boolean)*): Boolean = {
+ def checkText(scalaFile: String, checks: List[String], debug: Boolean = true): Boolean = {
val htmlFile = scalaFile.stripSuffix(".scala") + ".html"
- val htmlAllFiles = createTemplates(scalaFile)
+ val htmlText = createTemplates(scalaFile)(htmlFile).text.replace('→',' ').replaceAll("\\s+","")
var result = true
- for ((fileHint, check, expected) <- checks) {
- // resolve the file to be checked
- val fileName = fileHint match {
- case Some(file) =>
- if (file endsWith ".html")
- file
- else
- file + ".html"
- case None =>
- htmlFile
- }
- val fileText = htmlAllFiles(fileName).text.replace('→',' ').replaceAll("\\s+","")
- val checkText = check.replace('→',' ').replaceAll("\\s+","")
- val checkValue = fileText.contains(checkText) == expected
- if (debug && (!checkValue)) {
- Console.err.println("Check failed: ")
- Console.err.println("HTML: " + fileText)
- Console.err.println("Check: " + checkText)
- }
- result &&= checkValue
+ for (check <- checks) {
+ val checkText = check.replace('→',' ').replaceAll("\\s+","")
+ val checkValue = htmlText.contains(checkText)
+ if (debug && (!checkValue)) {
+ Console.err.println("Check failed: ")
+ Console.err.println("HTML: " + htmlText)
+ Console.err.println("Check: " + checkText)
+ }
+ result &&= checkValue
}
result
@@ -432,155 +426,40 @@ object Test extends Properties("HtmlFactory") {
createTemplate("SI_4898.scala")
true
}
-
+
property("Use cases should override their original members") =
- checkText("SI_5054_q1.scala")(
- (None,"""def test(): Int""", true),
- (None,"""def test(implicit lost: Int): Int""", false)
- )
+ checkText1("SI_5054_q1.scala", """def test(): Int""") &&
+ !checkText1("SI_5054_q1.scala", """def test(implicit lost: Int): Int""")
+
property("Use cases should keep their flags - final should not be lost") =
- checkText("SI_5054_q2.scala")((None, """final def test(): Int""", true))
+ checkText1("SI_5054_q2.scala", """final def test(): Int""")
property("Use cases should keep their flags - implicit should not be lost") =
- checkText("SI_5054_q3.scala")((None, """implicit def test(): Int""", true))
-
+ checkText1("SI_5054_q3.scala", """implicit def test(): Int""")
+
property("Use cases should keep their flags - real abstract should not be lost") =
- checkText("SI_5054_q4.scala")((None, """abstract def test(): Int""", true))
+ checkText1("SI_5054_q4.scala", """abstract def test(): Int""")
property("Use cases should keep their flags - traits should not be affected") =
- checkText("SI_5054_q5.scala")((None, """def test(): Int""", true))
+ checkText1("SI_5054_q5.scala", """def test(): Int""")
property("Use cases should keep their flags - traits should not be affected") =
- checkText("SI_5054_q6.scala")((None, """abstract def test(): Int""", true))
+ checkText1("SI_5054_q6.scala", """abstract def test(): Int""")
property("Use case individual signature test") =
- checkText("SI_5054_q7.scala")(
- (None, """abstract def test2(explicit: Int): Int [use case] This takes the explicit value passed.""", true),
- (None, """abstract def test1(): Int [use case] This takes the implicit value in scope.""", true)
- )
+ checkText("SI_5054_q7.scala", List(
+ """abstract def test2(explicit: Int): Int [use case] This takes the explicit value passed.""",
+ """abstract def test1(): Int [use case] This takes the implicit value in scope."""))
property("Display correct \"Definition classes\"") =
- checkText("SI_5287.scala")(
- (None,
- """def method(): Int
+ checkText1("SI_5287.scala",
+ """def method(): Int
[use case] The usecase explanation
[use case] The usecase explanation
- Definition Classes SI_5287 SI_5287_B SI_5287_A""", true)
- ) // the explanation appears twice, as small comment and full comment
+ Definition Classes SI_5287 SI_5287_B SI_5287_A""", debug=true)
+ // explanation appears twice, as small comment and full comment
-
- property("Correct comment inheritance for overriding") =
- checkText("implicit-inheritance-override.scala")(
- (Some("Base"),
- """def function[T](arg1: T, arg2: String): Double
- The base comment.
- The base comment. And another sentence...
- T the type of the first argument
- arg1 The T term comment
- arg2 The string comment
- returns The return comment
- """, true),
- (Some("DerivedA"),
- """def function[T](arg1: T, arg2: String): Double
- Overriding the comment, the params and returns comments should stay the same.
- Overriding the comment, the params and returns comments should stay the same.
- T the type of the first argument
- arg1 The T term comment
- arg2 The string comment
- returns The return comment
- """, true),
- (Some("DerivedB"),
- """def function[T](arg1: T, arg2: String): Double
- T the type of the first argument
- arg1 The overridden T term comment
- arg2 The overridden string comment
- returns The return comment
- """, true),
- (Some("DerivedC"),
- """def function[T](arg1: T, arg2: String): Double
- T the type of the first argument
- arg1 The T term comment
- arg2 The string comment
- returns The overridden return comment
- """, true),
- (Some("DerivedD"),
- """def function[T](arg1: T, arg2: String): Double
- T The overriden type parameter comment
- arg1 The T term comment
- arg2 The string comment
- returns The return comment
- """, true)
- )
-
- for (useCaseFile <- List("UseCaseInheritance", "UseCaseOverrideInheritance")) {
- property("Correct comment inheritance for usecases") =
- checkText("implicit-inheritance-usecase.scala")(
- (Some(useCaseFile),
- """def missing_arg[T](arg1: T): Double
- [use case]
- [use case]
- T The type parameter
- arg1 The T term comment
- returns The return comment
- """, true),
- (Some(useCaseFile),
- """def missing_targ(arg1: Int, arg2: String): Double
- [use case]
- [use case]
- arg1 The T term comment
- arg2 The string comment
- returns The return comment
- """, true),
- (Some(useCaseFile),
- """def overridden_arg1[T](implicit arg1: T, arg2: String): Double
- [use case]
- [use case]
- T The type parameter
- arg1 The overridden T term comment
- arg2 The string comment
- returns The return comment
- """, true),
- (Some(useCaseFile),
- """def overridden_targ[T](implicit arg1: T, arg2: String): Double
- [use case]
- [use case]
- T The overridden type parameter comment
- arg1 The T term comment
- arg2 The string comment
- returns The return comment
- """, true),
- (Some(useCaseFile),
- """def overridden_return[T](implicit arg1: T, arg2: String): Double
- [use case]
- [use case]
- T The type parameter
- arg1 The T term comment
- arg2 The string comment
- returns The overridden return comment
- """, true),
- (Some(useCaseFile),
- """def added_arg[T](implicit arg1: T, arg2: String, arg3: Float): Double
- [use case]
- [use case]
- T The type parameter
- arg1 The T term comment
- arg2 The string comment
- arg3 The added float comment
- returns The return comment
- """, true),
- (Some(useCaseFile),
- """def overridden_comment[T](implicit arg1: T, arg2: String): Double
- [use case] The overridden comment.
- [use case] The overridden comment.
- T The type parameter
- arg1 The T term comment
- arg2 The string comment
- returns The return comment
- """, true)
- )
- }
-
{
val files = createTemplates("basic.scala")
//println(files)