diff options
-rw-r--r-- | src/Kotlin/ContentBuilder.kt | 20 | ||||
-rw-r--r-- | test/src/model/FunctionTest.kt | 10 | ||||
-rw-r--r-- | test/src/model/PropertyTest.kt | 8 |
3 files changed, 28 insertions, 10 deletions
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index 4d9b0c06..f4e81400 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -2,6 +2,7 @@ package org.jetbrains.dokka import org.intellij.markdown.MarkdownElementTypes import org.intellij.markdown.MarkdownTokenTypes +import org.intellij.markdown.html.entities.EntityConverter import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.kdoc.getResolutionScope @@ -88,7 +89,24 @@ public fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver parent.append(block) } - MarkdownTokenTypes.TEXT, + MarkdownTokenTypes.TEXT -> { + fun createEntityOrText(text: String): ContentNode { + if (text == "&" || text == """ || text == "<" || text == ">") { + return ContentEntity(text) + } + if (text == "&") { + return ContentEntity("&") + } + val decodedText = EntityConverter.replaceEntities(text, true, true) + if (decodedText != text) { + return ContentEntity(text) + } + return ContentText(text) + } + + parent.append(createEntityOrText(node.text)) + } + MarkdownTokenTypes.COLON, MarkdownTokenTypes.DOUBLE_QUOTE, MarkdownTokenTypes.LT, diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt index e40777af..bbb7cdbc 100644 --- a/test/src/model/FunctionTest.kt +++ b/test/src/model/FunctionTest.kt @@ -1,8 +1,10 @@ package org.jetbrains.dokka.tests +import org.jetbrains.dokka.Content +import org.jetbrains.dokka.DocumentationNode import org.junit.Test -import kotlin.test.* -import org.jetbrains.dokka.* +import kotlin.test.assertEquals +import kotlin.test.assertTrue public class FunctionTest { Test fun function() { @@ -28,7 +30,6 @@ public class FunctionTest { assertEquals("fn", name) assertEquals(DocumentationNode.Kind.Function, kind) assertEquals("Function with receiver", content.summary.toTestString()) - assertEquals(4, details.count()) assertEquals("internal", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) with(details.elementAt(2)) { @@ -58,7 +59,6 @@ public class FunctionTest { assertEquals(DocumentationNode.Kind.Function, kind) assertEquals("generic function", content.summary.toTestString()) - assertEquals(4, details.count()) assertEquals("private", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) with(details.elementAt(2)) { @@ -83,7 +83,6 @@ public class FunctionTest { assertEquals(DocumentationNode.Kind.Function, kind) assertEquals("generic function", content.summary.toTestString()) - assertEquals(5, details.count()) assertEquals("public", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) with(details.elementAt(2)) { @@ -125,7 +124,6 @@ public class FunctionTest { assertEquals("""Function Documentation""", content.description.toTestString()) - assertEquals(4, details.count()) assertEquals("internal", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) with(details.elementAt(2)) { diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt index 93a0f681..38c3160f 100644 --- a/test/src/model/PropertyTest.kt +++ b/test/src/model/PropertyTest.kt @@ -1,8 +1,11 @@ package org.jetbrains.dokka.tests +import org.jetbrains.dokka.Content +import org.jetbrains.dokka.DocumentationNode +import org.jetbrains.dokka.DocumentationReference import org.junit.Test -import kotlin.test.* -import org.jetbrains.dokka.* +import kotlin.test.assertEquals +import kotlin.test.assertTrue public class PropertyTest { Test fun valueProperty() { @@ -50,7 +53,6 @@ public class PropertyTest { assertEquals("property", name) assertEquals(DocumentationNode.Kind.Property, kind) assertEquals(Content.Empty, content) - assertEquals(4, details.count()) assertEquals("String", detail(DocumentationNode.Kind.Type).name) val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name } assertTrue("final" in modifiers) |