aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/test/kotlin
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-07-30 17:06:47 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-08-20 16:56:21 +0200
commit0da70311b0535bbda18540d957570a46d19484f5 (patch)
treebfcd6d62b01f4f9090be148a5dfe28dd6e46cb71 /plugins/javadoc/src/test/kotlin
parente43478f9fe4a362c95276ef4de1eb3f5827e23bb (diff)
downloaddokka-0da70311b0535bbda18540d957570a46d19484f5.tar.gz
dokka-0da70311b0535bbda18540d957570a46d19484f5.tar.bz2
dokka-0da70311b0535bbda18540d957570a46d19484f5.zip
Javadoc package-list
Diffstat (limited to 'plugins/javadoc/src/test/kotlin')
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt11
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocTest.kt69
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt4
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/packagelist/JavadocPackageListTest.kt74
4 files changed, 81 insertions, 77 deletions
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<JavadocPlugin>()
.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<JavadocPlugin>().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<Int>
- |class Test2() : List<Int>
- |/jvmSrc/javadoc/TestJ.java
- |package javadoc
- |abstract class Test3 extends List<Int> {}
- """.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<JavadocPlugin>().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