From fb8854ab6b8b3751b797d01efcbea5b4653007b8 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 17 Jan 2017 10:56:15 +0100 Subject: Fix trailing bullet lists --- .../tools/dottydoc/model/comment/MarkdownShortener.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc-tool') diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/MarkdownShortener.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/MarkdownShortener.scala index 841232e52..8ad8024ae 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/comment/MarkdownShortener.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/MarkdownShortener.scala @@ -14,6 +14,7 @@ class MarkdownShortener { def shorten(node: Node, maxLen: Int = 150): Node = { var len = 0 + var didUnlinkBullets = false def count(node: Node, length: => Int, shortenOrUnlink: Int => Unit) = { val remaining = math.max(maxLen - len, 0) @@ -48,6 +49,17 @@ class MarkdownShortener { }), new VisitHandler(classOf[Image], new Visitor[Image] { override def visit(node: Image) = count(node, maxLen, _ => node.unlink()) + }), + new VisitHandler(classOf[BulletListItem], new Visitor[BulletListItem] { + override def visit(node: BulletListItem) = count( + node, + if (didUnlinkBullets) maxLen + else node.getSegments.map(_.length).reduceLeft(_ + _), + _ => { + node.unlink() + didUnlinkBullets = true // unlink all following bullets + } + ) }) ) -- cgit v1.2.3