diff options
Diffstat (limited to 'plugins/javadoc/src')
3 files changed, 155 insertions, 13 deletions
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt index a79c6b20..80814103 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt @@ -84,7 +84,7 @@ open class JavadocPageCreator(context: DokkaContext) { JavadocContentKind.OverviewSummary, m.sourceSets.toDisplaySourceSets() ) { - title(m.name, m.brief(), documentationVersion, dri = setOf(m.dri), kind = ContentKind.Main) + title(m.name, m.descriptionToContentNodes(), documentationVersion, dri = setOf(m.dri), kind = ContentKind.Main) leafList(setOf(m.dri), ContentKind.Packages, JavadocList( "Packages", "Package", @@ -103,7 +103,7 @@ open class JavadocPageCreator(context: DokkaContext) { JavadocContentKind.PackageSummary, p.sourceSets.toDisplaySourceSets() ) { - title("Package ${p.name}", p.brief(), dri = setOf(p.dri), kind = ContentKind.Packages) + title("Package ${p.name}", p.descriptionToContentNodes(), dri = setOf(p.dri), kind = ContentKind.Packages) fun allClasslikes(c: DClasslike): List<DClasslike> = c.classlikes.flatMap { allClasslikes(it) } + c val rootList = p.classlikes.map { allClasslikes(it) }.flatten().groupBy { it::class }.map { (key, value) -> JavadocList(key.tabTitle, key.colTitle, value.map { c -> 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()) } } } |