diff options
author | Vadim Mishenev <vad-mishenev@yandex.ru> | 2022-08-30 16:17:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-30 16:17:54 +0300 |
commit | c9f1d60af8776c14d35ed11f512c3c7b0dfad3a2 (patch) | |
tree | b1013542fddd5a3e036161d55da9728ef07e841a /plugins/base/src/test/kotlin | |
parent | a4bccbf8920a2f6f5fcf5bdf1f201d1129a05b62 (diff) | |
download | dokka-c9f1d60af8776c14d35ed11f512c3c7b0dfad3a2.tar.gz dokka-c9f1d60af8776c14d35ed11f512c3c7b0dfad3a2.tar.bz2 dokka-c9f1d60af8776c14d35ed11f512c3c7b0dfad3a2.zip |
Fix missing space between Markdown elements (#2640)
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r-- | plugins/base/src/test/kotlin/markdown/ParserTest.kt | 53 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/model/CommentTest.kt | 16 |
2 files changed, 67 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt index 3498f73f..8e813eba 100644 --- a/plugins/base/src/test/kotlin/markdown/ParserTest.kt +++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt @@ -2,16 +2,18 @@ package org.jetbrains.dokka.tests import markdown.KDocTest import org.intellij.markdown.MarkdownElementTypes +import org.jetbrains.dokka.base.parsers.MarkdownParser import org.jetbrains.dokka.model.doc.* import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows import kotlin.test.assertEquals -import kotlin.test.assertTrue class ParserTest : KDocTest() { + private fun parseMarkdownToDocNode(text: String) = + MarkdownParser( { null }, "").parseStringToDocNode(text) + @Test fun `Simple text`() { val kdoc = """ @@ -1519,5 +1521,52 @@ class ParserTest : KDocTest() { ) executeTest(kdoc, expectedDocumentationNode) } + + @Test + fun `code with backticks`() { + val kdoc = "` `` ` ` ``` `" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + CustomDocTag( + listOf( + P( + listOf( + CodeInline(listOf(Text("`` "))), + Text(" "), + CodeInline(listOf(Text("``` "))), + ) + ) + ), name = MarkdownElementTypes.MARKDOWN_FILE.name + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test + fun `should filter spaces in markdown`() { + val markdown = """ + | sdsdds f,*()hhh + | dssd hf + | + | sdsdsds sdd + | + | + | eweww + | + | + | + """.trimMargin() + val actualDocumentationNode = parseMarkdownToDocNode(markdown).children + val expectedDocumentationNode = listOf( + P(listOf(Text(" sdsdds f,*()hhh dssd hf"))), + P(listOf(Text(" sdsdsds sdd"))), + P(listOf(Text(" eweww "))) + ) + print(expectedDocumentationNode) + assertEquals(actualDocumentationNode, expectedDocumentationNode) + } } diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt index 6a7b2d89..0742587a 100644 --- a/plugins/base/src/test/kotlin/model/CommentTest.kt +++ b/plugins/base/src/test/kotlin/model/CommentTest.kt @@ -251,4 +251,20 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme } } } + + @Test + fun `should be space between Markdown nodes`() { + inlineModelTest( + """ + |/** + | * Rotates paths by `amount` **radians** around (`x`, `y`). + | */ + |val property = "test" + """ + ) { + with((this / "comment" / "property").cast<DProperty>()) { + comments() equals "Rotates paths by amount radians around (x, y).\n" + } + } + } } |