From 0da70311b0535bbda18540d957570a46d19484f5 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 30 Jul 2020 17:06:47 +0200 Subject: Javadoc package-list --- .../javadoc/AbstractJavadocTemplateMapTest.kt | 11 ++-- .../org/jetbrains/dokka/javadoc/JavadocTest.kt | 69 -------------------- .../dokka/javadoc/location/JavadocLocationTest.kt | 4 +- .../javadoc/packagelist/JavadocPackageListTest.kt | 74 ++++++++++++++++++++++ 4 files changed, 81 insertions(+), 77 deletions(-) create mode 100644 plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/packagelist/JavadocPackageListTest.kt (limited to 'plugins/javadoc/src/test/kotlin') diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt index e37f8daf..09feebe9 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt @@ -3,14 +3,12 @@ package org.jetbrains.dokka.javadoc import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.ExternalDocumentationLink import org.jetbrains.dokka.javadoc.pages.JavadocPageNode -import org.jetbrains.dokka.javadoc.pages.preprocessors import org.jetbrains.dokka.javadoc.renderer.JavadocContentToTemplateMapTranslator +import org.jetbrains.dokka.javadoc.JavadocPlugin +import org.jetbrains.dokka.javadoc.location.JavadocLocationProvider import org.jetbrains.dokka.model.withDescendants import org.jetbrains.dokka.pages.RootPageNode -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.plugin -import org.jetbrains.dokka.plugability.querySingle +import org.jetbrains.dokka.plugability.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() { @@ -36,7 +34,7 @@ internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() { val translator: JavadocContentToTemplateMapTranslator by lazy { val locationProvider = context.plugin() .querySingle { locationProviderFactory } - .getLocationProvider(rootPageNode) + .getLocationProvider(rootPageNode) as JavadocLocationProvider JavadocContentToTemplateMapTranslator(locationProvider, context) } @@ -68,6 +66,7 @@ internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() { ) { testInline(query, configuration, pluginOverrides = pluginsOverride) { renderingStage = { rootPageNode, dokkaContext -> + val preprocessors = dokkaContext.plugin().query { javadocPreprocessors } val transformedRootPageNode = preprocessors.fold(rootPageNode) { acc, pageTransformer -> pageTransformer(acc) } diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocTest.kt index 9adcc2e0..e69de29b 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocTest.kt @@ -1,69 +0,0 @@ -package org.jetbrains.dokka.javadoc - -import org.jetbrains.dokka.javadoc.JavadocPlugin -import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest -import org.junit.jupiter.api.Test - -class JavadocTest : AbstractCoreTest() { - - @Test - fun test() { - val config = dokkaConfiguration { - format = "javadoc" - sourceSets { - sourceSet { - sourceRoots = listOf("jvmSrc/") - analysisPlatform = "jvm" - } - } - } - - /* - |/jvmSrc/javadoc/test/Test2.kt - |package javadoc.test - |class Test2() - */ - - testInline(""" - |/jvmSrc/javadoc/Test.kt - |/** - | test - |**/ - |package javadoc - |class Test() : List - |class Test2() : List - |/jvmSrc/javadoc/TestJ.java - |package javadoc - |abstract class Test3 extends List {} - """.trimIndent(), - config, - cleanupOutput = false, - pluginOverrides = listOf(JavadocPlugin()) - ) { - pagesTransformationStage = { - it - } - } - } - -// @Test -// fun test() { -// val config = dokkaConfiguration { -// format = "javadoc" -// passes { -// pass { -// sourceRoots = listOf("main/") -// analysisPlatform = "jvm" -// targets = listOf("jvm") -// } -// } -// } -// testFromData(config, -// cleanupOutput = false, -// pluginOverrides = listOf(JavadocPlugin())) { -// pagesTransformationStage = { -// it -// } -// } -// } -} diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt index afea5914..87de4228 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt @@ -16,7 +16,7 @@ import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions.assertEquals -class JavadocTest : AbstractCoreTest() { +class JavadocLocationTest : AbstractCoreTest() { private fun locationTestInline(testHandler: (RootPageNode, DokkaContext) -> Unit) { fun externalLink(link: String) = ExternalDocumentationLink(link) @@ -134,7 +134,7 @@ class JavadocTest : AbstractCoreTest() { private fun htmlTranslator(rootPageNode: RootPageNode, dokkaContext: DokkaContext): JavadocContentToHtmlTranslator { val locationProvider = dokkaContext.plugin().querySingle { locationProviderFactory } - .getLocationProvider(rootPageNode) + .getLocationProvider(rootPageNode) as JavadocLocationProvider return htmlTranslator(dokkaContext, locationProvider) } diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/packagelist/JavadocPackageListTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/packagelist/JavadocPackageListTest.kt new file mode 100644 index 00000000..f31b5793 --- /dev/null +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/packagelist/JavadocPackageListTest.kt @@ -0,0 +1,74 @@ +package org.jetbrains.dokka.javadoc.packagelist + +import org.jetbrains.dokka.javadoc.AbstractJavadocTemplateMapTest +import org.junit.jupiter.api.Test +import utils.TestOutputWriterPlugin +import org.junit.jupiter.api.Assertions.* + +internal class JavadocPackageListTest : AbstractJavadocTemplateMapTest() { + @Test + fun `package list should be generated for a flat structure`(){ + val writerPlugin = TestOutputWriterPlugin() + dualTestTemplateMapInline( + java = """ + /src/package0/ClassA.java + package package0 + public class ClassA { + + } + + /src/package1/ClassB.java + package package1 + public class ClassB { + } + """, + pluginsOverride = listOf(writerPlugin) + ){ + val contents = writerPlugin.writer.contents + val expected = """ + ${'$'}dokka.format:dokkaJavadoc + ${'$'}dokka.linkExtension:html + + package0 + package1 + """.trimIndent() + assertEquals(expected, contents["/package-list"]?.trimIndent()) + } + } + + @Test + fun `package list should be generated for nested structure`(){ + val writerPlugin = TestOutputWriterPlugin() + dualTestTemplateMapInline( + java = """ + /src/package0/ClassA.java + package package0 + public class ClassA { + + } + + /src/package0/package0Inner/ClassB.java + package package0.package0Inner + public class ClassB { + } + + /src/package1/package1Inner/package1InnerInner/ClassC.java + package package1.package1Inner.package1InnerInner + public class ClassC { + } + """, + pluginsOverride = listOf(writerPlugin) + ){ + val contents = writerPlugin.writer.contents + val expected = """ + ${'$'}dokka.format:dokkaJavadoc + ${'$'}dokka.linkExtension:html + + package0 + package0.package0Inner + package1.package1Inner.package1InnerInner + """.trimIndent() + assertEquals(expected, contents["/package-list"]?.trimIndent()) + } + } +} \ No newline at end of file -- cgit