Skip to content

Commit 86fe7de

Browse files
gourlaysamalrytz
authored andcommitted
SI-9752 never ignore blank lines when parsing code blocks (scala#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.
1 parent 5c2a2f7 commit 86fe7de

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
295295
}
296296

297297
case line :: ls if (lastTagKey.isDefined) => {
298-
val newtags = if (!line.isEmpty) {
298+
val newtags = if (!line.isEmpty || inCodeBlock) {
299299
val key = lastTagKey.get
300300
val value =
301301
((tags get key): @unchecked) match {

test/scaladoc/run/t9752.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
List(Body(List(Paragraph(Chain(List(Summary(Text())))), Code(class A
2+
3+
4+
class B))))
5+
Done.

test/scaladoc/run/t9752.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import scala.tools.nsc.doc.model._
2+
import scala.tools.partest.ScaladocModelTest
3+
4+
object Test extends ScaladocModelTest {
5+
6+
override def code = s"""
7+
/**
8+
* Foo
9+
*
10+
* @example
11+
* {{{
12+
* class A
13+
*
14+
*
15+
* class B
16+
* }}}
17+
*/
18+
object Foo
19+
"""
20+
21+
def scaladocSettings = ""
22+
23+
def testModel(root: Package) = {
24+
import access._
25+
val obj = root._object("Foo")
26+
println(obj.comment.get.example)
27+
}
28+
}

0 commit comments

Comments
 (0)