From c9f1d60af8776c14d35ed11f512c3c7b0dfad3a2 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Tue, 30 Aug 2022 16:17:54 +0300 Subject: Fix missing space between Markdown elements (#2640) --- .../base/src/test/kotlin/markdown/ParserTest.kt | 53 +++++++++++++++++++++- plugins/base/src/test/kotlin/model/CommentTest.kt | 16 +++++++ 2 files changed, 67 insertions(+), 2 deletions(-) (limited to 'plugins/base/src/test/kotlin') 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()) { + comments() equals "Rotates paths by amount radians around (x, y).\n" + } + } + } } -- cgit