diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-08-27 12:47:31 +0200 |
---|---|---|
committer | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2020-09-14 13:44:34 +0200 |
commit | ba05c354a353ac3145c775e190b96b2bbe3c1227 (patch) | |
tree | 9a9b432cf5784b0ac0e8a9b35ecdce727d249aa6 /plugins/base/src/test/kotlin/markdown | |
parent | 30d6e6c3d82993e76c3942fc9faf102f36736673 (diff) | |
download | dokka-ba05c354a353ac3145c775e190b96b2bbe3c1227.tar.gz dokka-ba05c354a353ac3145c775e190b96b2bbe3c1227.tar.bz2 dokka-ba05c354a353ac3145c775e190b96b2bbe3c1227.zip |
Refactor DocTags and add markdown tests
Diffstat (limited to 'plugins/base/src/test/kotlin/markdown')
-rw-r--r-- | plugins/base/src/test/kotlin/markdown/ParserTest.kt | 119 |
1 files changed, 118 insertions, 1 deletions
diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt index e127afc2..268af405 100644 --- a/plugins/base/src/test/kotlin/markdown/ParserTest.kt +++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt @@ -1169,7 +1169,7 @@ class ParserTest : KDocTest() { } @Test - fun image(){ + fun image() { val kdoc = "![Sample image](https://www.google.pl/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png)" val expectedDocumentationNode = DocumentationNode( listOf( @@ -1190,5 +1190,122 @@ class ParserTest : KDocTest() { ) executeTest(kdoc, expectedDocumentationNode) } + + @Test + fun `Bold + italic + link`() { + val kdoc = "It's very easy to make some words **bold** and other words *italic* with Markdown.\n" + + "You can even [link to Google!](http://google.com)" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P( + listOf( + Text("It's very easy to make some words "), + B(listOf(Text("bold"))), + Text(" and other words "), + I(listOf(Text("italic"))), + Text(" with Markdown. You can even "), + A(listOf(Text("link to Google!")), mapOf("href" to "http://google.com")) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test + fun `Codeblock from indent`() { + val kdoc = "Here is some example how to use conditional instructions:\n\n" + + " val x = 1\n" + + " val y = 2\n" + + " if (x == 1) {\n" + + " println(y)\n" + + " }" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P( + listOf( + P(listOf(Text("Here is some example how to use conditional instructions:"))), + CodeBlock( + listOf( + Text( + " val x = 1\n" + + " val y = 2\n" + + " if (x == 1) {\n" + + " println(y)\n" + + " }" + ) + ) + ) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test + fun `Table`() { + val kdoc = "First Header | Second Header\n" + + "------------ | -------------\n" + + "Content from cell 1 | Content from cell 2\n" + + "Content in the first column | Content in the second column" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Table( + listOf( + Th( + listOf( + Td( + listOf( + Text("First Header") + ) + ), + Td( + listOf( + Text("Second Header") + ) + ) + ) + ), + Tr( + listOf( + Td( + listOf( + Text("Content from cell 1") + ) + ), + Td( + listOf( + Text("Content from cell 2") + ) + ) + ) + ), + Tr( + listOf( + Td( + listOf( + Text("Content in the first column") + ) + ), + Td( + listOf( + Text("Content in the second column") + ) + ) + ) + ) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } } |