summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2016-05-02 15:36:09 +0200
committerLukas Rytz <lukas.rytz@typesafe.com>2016-05-02 15:36:09 +0200
commit86fe7de15988ea511fdc5e4f44039154cd236149 (patch)
tree151edcfe12e7916c3186bd5955e23143e0a8d643
parent5c2a2f725dccd0c4616a042e29c5b9e95d004192 (diff)
downloadscala-86fe7de15988ea511fdc5e4f44039154cd236149.tar.gz
scala-86fe7de15988ea511fdc5e4f44039154cd236149.tar.bz2
scala-86fe7de15988ea511fdc5e4f44039154cd236149.zip
SI-9752 never ignore blank lines when parsing code blocks (#5125)
The default behavior when parsing the content of a tag text (like after `@example`) was to ignore empty lines. That's fine, except when we are in the middle of a code block, where preserving formatting matters.
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala2
-rw-r--r--test/scaladoc/run/t9752.check5
-rw-r--r--test/scaladoc/run/t9752.scala28
3 files changed, 34 insertions, 1 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala b/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
index 8cd8a7ee09..d3b4bf8ff5 100644
--- a/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
@@ -295,7 +295,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
}
case line :: ls if (lastTagKey.isDefined) => {
- val newtags = if (!line.isEmpty) {
+ val newtags = if (!line.isEmpty || inCodeBlock) {
val key = lastTagKey.get
val value =
((tags get key): @unchecked) match {
diff --git a/test/scaladoc/run/t9752.check b/test/scaladoc/run/t9752.check
new file mode 100644
index 0000000000..daeafb8ecc
--- /dev/null
+++ b/test/scaladoc/run/t9752.check
@@ -0,0 +1,5 @@
+List(Body(List(Paragraph(Chain(List(Summary(Text())))), Code(class A
+
+
+class B))))
+Done.
diff --git a/test/scaladoc/run/t9752.scala b/test/scaladoc/run/t9752.scala
new file mode 100644
index 0000000000..b11c7f5c32
--- /dev/null
+++ b/test/scaladoc/run/t9752.scala
@@ -0,0 +1,28 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ override def code = s"""
+ /**
+ * Foo
+ *
+ * @example
+ * {{{
+ * class A
+ *
+ *
+ * class B
+ * }}}
+ */
+ object Foo
+ """
+
+ def scaladocSettings = ""
+
+ def testModel(root: Package) = {
+ import access._
+ val obj = root._object("Foo")
+ println(obj.comment.get.example)
+ }
+}