diff options
author | Marcin K <github@anubis.email> | 2022-11-22 22:16:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 22:16:00 +0100 |
commit | dc1f9d20f599ca8f9311b779645bc5e53784ca92 (patch) | |
tree | 81a183dbd40eff0ee2ec4c148d058ee8ec689d2a /plugins/javadoc/src/test/kotlin/org | |
parent | f6e5bd673f68c7de644c27c7e8e9f9f1080018fb (diff) | |
download | dokka-dc1f9d20f599ca8f9311b779645bc5e53784ca92.tar.gz dokka-dc1f9d20f599ca8f9311b779645bc5e53784ca92.tar.bz2 dokka-dc1f9d20f599ca8f9311b779645bc5e53784ca92.zip |
Fix package and module description truncation in javadoc (#2751)
Diffstat (limited to 'plugins/javadoc/src/test/kotlin/org')
2 files changed, 153 insertions, 11 deletions
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocModuleTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocModuleTemplateMapTest.kt index d192abde..f6b8439f 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocModuleTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocModuleTemplateMapTest.kt @@ -3,9 +3,10 @@ package org.jetbrains.dokka.javadoc import org.jetbrains.dokka.javadoc.pages.JavadocModulePageNode import org.jetbrains.dokka.javadoc.pages.RowJavadocListEntry import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.test.assertIsInstance import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import org.jetbrains.dokka.test.assertIsInstance +import java.io.File internal class JavadocModuleTemplateMapTest : AbstractJavadocTemplateMapTest() { @@ -77,4 +78,70 @@ internal class JavadocModuleTemplateMapTest : AbstractJavadocTemplateMapTest() { assertEquals(DRI("com.test.package1"), assertIsInstance<RowJavadocListEntry>(list[1]).link.dri.single()) } } + + @Test + fun `single class with module documentation (kotlin)`() { + testTemplateMapInline( + query = + """ + /src/module.md + # Module module1 + ABC + + /src/source0.kt + package com.test.package0 + class Test + """, + configuration = config.copy( + sourceSets = config.sourceSets.map { sourceSet -> + sourceSet.copy( + includes = setOf(File("src/module.md")) + ) + }, + moduleName = "module1" + ) + ) { + val modulePage = singlePageOfType<JavadocModulePageNode>() + + val map = modulePage.templateMap + assertEquals("<p>ABC</p>", map["subtitle"].toString().trim()) + } + } + + @Test + fun `single class with long module documentation (kotlin)`() { + testTemplateMapInline( + query = + """ + /src/module.md + # Module module1 + Aliquam rerum est vel. Molestiae eos expedita animi repudiandae sed commodi. + Omnis qui ducimus ut et perspiciatis sint. + + Veritatis nam eaque sequi laborum voluptas voluptate aut. + + /src/source0.kt + package com.test.package0 + class Test + """, + configuration = config.copy( + sourceSets = config.sourceSets.map { sourceSet -> + sourceSet.copy( + includes = setOf(File("src/module.md")) + ) + }, + moduleName = "module1" + ) + ) { + val modulePage = singlePageOfType<JavadocModulePageNode>() + + val map = modulePage.templateMap + val expectedText = """ + <p>Aliquam rerum est vel. Molestiae eos expedita animi repudiandae sed commodi. + Omnis qui ducimus ut et perspiciatis sint.</p> + <p>Veritatis nam eaque sequi laborum voluptas voluptate aut.</p> + """.trimIndent().replace("\n", "") + assertEquals(expectedText, map["subtitle"].toString().trim()) + } + } } diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocPackageTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocPackageTemplateMapTest.kt index 592d7b0d..4a761ca6 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocPackageTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocPackageTemplateMapTest.kt @@ -4,10 +4,9 @@ import org.jetbrains.dokka.javadoc.pages.JavadocContentKind import org.jetbrains.dokka.javadoc.pages.JavadocPackagePageNode import org.jetbrains.dokka.javadoc.pages.RowJavadocListEntry import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.test.assertIsInstance import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.jetbrains.dokka.test.assertIsInstance import java.io.File internal class JavadocPackageTemplateMapTest : AbstractJavadocTemplateMapTest() { @@ -82,11 +81,33 @@ internal class JavadocPackageTemplateMapTest : AbstractJavadocTemplateMapTest() } } - @Disabled("To be implemented / To be fixed") @Test - fun `single class with package documentation`() { - dualTestTemplateMapInline( - kotlin = + fun `single class with package documentation (java)`() { + testTemplateMapInline( + query = + """ + /src/com/test/package0/package-info.java + /** + * ABC + */ + package com.test.package0; + + /src/com/test/package0/Test.java + package com.test.package0; + public class Test{} + """ + ) { + val packagePage = singlePageOfType<JavadocPackagePageNode>() + + val map = packagePage.templateMap + assertEquals("<p>ABC</p>", map["subtitle"].toString().trim()) + } + } + + @Test + fun `single class with package documentation (kotlin)`() { + testTemplateMapInline( + query = """ /src/packages.md # Package com.test.package0 @@ -96,23 +117,72 @@ internal class JavadocPackageTemplateMapTest : AbstractJavadocTemplateMapTest() package com.test.package0 class Test """, + configuration = config.copy( + sourceSets = config.sourceSets.map { sourceSet -> + sourceSet.copy( + includes = setOf(File("src/packages.md")) + ) + } + ) + ) { + val packagePage = singlePageOfType<JavadocPackagePageNode>() - java = + val map = packagePage.templateMap + assertEquals("<p>ABC</p>", map["subtitle"].toString().trim()) + } + } + + @Test + fun `single class with long package documentation (java)`() { + testTemplateMapInline( + query = """ /src/com/test/package0/package-info.java /** - * ABC + * Aliquam rerum est vel. Molestiae eos expedita animi repudiandae sed commodi. + * Omnis qui ducimus ut et perspiciatis sint. + * + * Veritatis nam eaque sequi laborum voluptas voluptate aut. */ package com.test.package0; /src/com/test/package0/Test.java package com.test.package0; public class Test{} + """ + ) { + val packagePage = singlePageOfType<JavadocPackagePageNode>() + + val map = packagePage.templateMap + val expectedText = """ + <p>Aliquam rerum est vel. Molestiae eos expedita animi repudiandae sed commodi. + Omnis qui ducimus ut et perspiciatis sint. + Veritatis nam eaque sequi laborum voluptas voluptate aut.</p> + """.trimIndent().replace("\n", "") + assertEquals(expectedText, map["subtitle"].toString().trim()) + } + } + + @Test + fun `single class with long package documentation (kotlin)`() { + testTemplateMapInline( + query = + """ + /src/packages.md + # Package com.test.package0 + Aliquam rerum est vel. Molestiae eos expedita animi repudiandae sed commodi. + Omnis qui ducimus ut et perspiciatis sint. + + Veritatis nam eaque sequi laborum voluptas voluptate aut. + + /src/source0.kt + package com.test.package0 + class Test """, configuration = config.copy( sourceSets = config.sourceSets.map { sourceSet -> sourceSet.copy( - includes = setOf(File("packages.md")) + includes = setOf(File("src/packages.md")) ) } ) @@ -120,7 +190,12 @@ internal class JavadocPackageTemplateMapTest : AbstractJavadocTemplateMapTest() val packagePage = singlePageOfType<JavadocPackagePageNode>() val map = packagePage.templateMap - assertEquals("ABD", map["subtitle"].toString().trim()) + val expectedText = """ + <p>Aliquam rerum est vel. Molestiae eos expedita animi repudiandae sed commodi. + Omnis qui ducimus ut et perspiciatis sint.</p> + <p>Veritatis nam eaque sequi laborum voluptas voluptate aut.</p> + """.trimIndent().replace("\n", "") + assertEquals(expectedText, map["subtitle"].toString().trim()) } } } |