diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-01-05 13:52:58 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-01-31 14:29:17 +0100 |
commit | 56cec80db7ab46c69cbbc8551ddf3c9857f8a804 (patch) | |
tree | bdb1f423438732bb71c9b15afefe09f34dd94f17 /doc-tool/test | |
parent | 08dce0704570ae8346fc28019ef5264f1e12ce25 (diff) | |
download | dotty-56cec80db7ab46c69cbbc8551ddf3c9857f8a804.tar.gz dotty-56cec80db7ab46c69cbbc8551ddf3c9857f8a804.tar.bz2 dotty-56cec80db7ab46c69cbbc8551ddf3c9857f8a804.zip |
Implement shortening of Markdown AST for summaries
Diffstat (limited to 'doc-tool/test')
-rw-r--r-- | doc-tool/test/MarkdownTests.scala | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/doc-tool/test/MarkdownTests.scala b/doc-tool/test/MarkdownTests.scala index e8596b634..144acbdfb 100644 --- a/doc-tool/test/MarkdownTests.scala +++ b/doc-tool/test/MarkdownTests.scala @@ -237,11 +237,73 @@ class MarkdownTests extends DottyDocTest { .flatMap(_.comment.map(_.body)) .get .trim - println(traitCmt) assertEquals( """|<pre><code class="language-scala">val x = 1 + 5 |</code></pre>""".stripMargin, traitCmt) } } + + @Test def docstringSummary = { + val source = + """ + |package scala + | + |/** This + | * ==== + | * is a short text [that](http://google.com) should not be more than a + | * `few` lines long. This text *should* be shortened somewhere that is + | * appropriate for the **ui**. Might be here, or there or somewhere + | * else. + | */ + |trait HelloWorld + """.stripMargin + + checkSource(source) { packages => + val traitCmt = + packages("scala") + .children.find(_.path.mkString(".") == "scala.HelloWorld") + .flatMap(_.comment.map(_.short)) + .get + .trim + + assert( + traitCmt.endsWith("Might be here...\n</p>"), + s"""|docstring summary should strip the following docstring so that it ends in "Might be here..." + | + |$traitCmt""".stripMargin + ) + } + } + + @Test def docstringSummaryWithImage = { + val source = + """ + |package scala + | + |/** This + | * ==== + | * should quit before ![alt text](https://whatever.com/1.png "Img Text"), + | * I shouldn't be visible. + | */ + |trait HelloWorld + """.stripMargin + + checkSource(source) { packages => + val traitCmt = + packages("scala") + .children.find(_.path.mkString(".") == "scala.HelloWorld") + .flatMap(_.comment.map(_.short)) + .get + .trim + + assert( + !traitCmt.contains("<img") && + !traitCmt.contains("I shouldn't be visible."), + s"""|docstring summary shouldn't contain image, error in `MarkdownShortener.scala` + | + |$traitCmt""".stripMargin) + } + + } } |