aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-07-12 09:58:38 +0200
committerGitHub <noreply@github.com>2021-07-12 09:58:38 +0200
commitcc6b2991df60f43607c8271d9657be89b3463a69 (patch)
treec705aa2808224a6b80de270ac65d61936e93f253 /plugins/base/src/test/kotlin
parent4548d1d929950c794b81cdad648bd2e0fd13a4e1 (diff)
downloaddokka-cc6b2991df60f43607c8271d9657be89b3463a69.tar.gz
dokka-cc6b2991df60f43607c8271d9657be89b3463a69.tar.bz2
dokka-cc6b2991df60f43607c8271d9657be89b3463a69.zip
Handle NBSP and other html entries (#2005)
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt113
1 files changed, 113 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt b/plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt
new file mode 100644
index 00000000..1a3bda5e
--- /dev/null
+++ b/plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt
@@ -0,0 +1,113 @@
+package content
+
+import junit.framework.Assert.assertEquals
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.model.doc.CustomDocTag
+import org.jetbrains.dokka.model.doc.Description
+import org.jetbrains.dokka.model.doc.P
+import org.jetbrains.dokka.model.doc.Text
+import org.junit.jupiter.api.Test
+import kotlin.test.assertTrue
+
+class ContentInDescriptionTest : BaseAbstractTest() {
+ private val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ analysisPlatform = "jvm"
+ classpath += jvmStdlibPath!!
+ }
+ }
+ }
+
+ val expectedDescription = Description(
+ CustomDocTag(
+ listOf(
+ P(
+ listOf(
+ Text("Hello World! Docs with period issue, e.g."),
+ Text(String(Character.toChars(160)), params = mapOf("content-type" to "html")),
+ Text("this.")
+ )
+ )
+ ),
+ params = emptyMap(),
+ name = "MARKDOWN_FILE"
+ )
+ )
+
+ @Test
+ fun `nbsp is handled as code in kotlin`() {
+ testInline(
+ """
+ |/src/main/kotlin/sample/ParentKt.kt
+ |package sample;
+ |/**
+ | * Hello World! Docs with period issue, e.g.&nbsp;this.
+ | */
+ |public class ParentKt {
+ |}
+ """.trimIndent(), configuration
+ ) {
+ documentablesMergingStage = {
+ val classlike = it.packages.flatMap { it.classlikes }.find { it.name == "ParentKt" }
+
+ assertTrue(classlike != null)
+ assertEquals(expectedDescription, classlike.documentation.values.first().children.first())
+ }
+ }
+ }
+
+ @Test
+ fun `nbsp is handled as code in java`() {
+ testInline(
+ """
+ |/src/main/kotlin/sample/Parent.java
+ |package sample;
+ |/**
+ | * Hello World! Docs with period issue, e.g.&nbsp;this.
+ | */
+ |public class Parent {
+ |}
+ """.trimIndent(), configuration
+ ) {
+ documentablesMergingStage = {
+ val classlike = it.packages.flatMap { it.classlikes }.find { it.name == "Parent" }
+
+ assertTrue(classlike != null)
+ assertEquals(expectedDescription, classlike.documentation.values.first().children.first())
+ }
+ }
+ }
+
+ @Test
+ fun `same documentation in java and kotlin when nbsp is present`() {
+ testInline(
+ """
+ |/src/main/kotlin/sample/Parent.java
+ |package sample;
+ |/**
+ | * Hello World! Docs with period issue, e.g.&nbsp;this.
+ | */
+ |public class Parent {
+ |}
+ |
+ |/src/main/kotlin/sample/ParentKt.kt
+ |package sample;
+ |/**
+ | * Hello World! Docs with period issue, e.g.&nbsp;this.
+ | */
+ |public class ParentKt {
+ |}
+ """.trimIndent(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ val java = module.packages.flatMap { it.classlikes }.first { it.name == "Parent" }
+ val kotlin = module.packages.flatMap { it.classlikes }.first { it.name == "ParentKt" }
+
+ assertEquals(java.documentation.values.first(), kotlin.documentation.values.first())
+ }
+ }
+ }
+} \ No newline at end of file