diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-07-05 10:04:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-05 10:04:55 +0200 |
commit | 9559158bfeeb274e9ccf1b4563f1b23b42afc493 (patch) | |
tree | 3ece0887623cfe2b7148af23001867a1dd5e6597 /plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt | |
parent | cbd9733d3dd2f52992e98e7cebd072091a572529 (diff) | |
download | dokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.tar.gz dokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.tar.bz2 dokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.zip |
Decompose Kotlin/Java analysis (#3034)
* Extract analysis into separate modules
Diffstat (limited to 'plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt')
-rw-r--r-- | plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt index 9f934f3f..e773a4da 100644 --- a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt @@ -1,16 +1,21 @@ package transformers -import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationReader + +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.analysis.markdown.jb.MARKDOWN_ELEMENT_FILE_NAME import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationTransformer import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.model.SourceSetDependent +import org.jetbrains.dokka.model.doc.CustomDocTag +import org.jetbrains.dokka.model.doc.Description import org.jetbrains.dokka.model.doc.DocumentationNode +import org.jetbrains.dokka.model.doc.Text +import org.jetbrains.kotlin.analysis.kotlin.internal.ModuleAndPackageDocumentationReader import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import testApi.testRunner.dPackage -import testApi.testRunner.documentationNode import testApi.testRunner.sourceSet @@ -20,8 +25,9 @@ class ModuleAndPackageDocumentationTransformerUnitTest { fun `empty list of modules`() { val transformer = ModuleAndPackageDocumentationTransformer( object : ModuleAndPackageDocumentationReader { - override fun get(module: DModule): SourceSetDependent<DocumentationNode> = throw NotImplementedError() - override fun get(pkg: DPackage): SourceSetDependent<DocumentationNode> = throw NotImplementedError() + override fun read(module: DModule): SourceSetDependent<DocumentationNode> = throw NotImplementedError() + override fun read(pkg: DPackage): SourceSetDependent<DocumentationNode> = throw NotImplementedError() + override fun read(module: DokkaConfiguration.DokkaModuleDescription): DocumentationNode = throw NotImplementedError() } ) @@ -34,13 +40,13 @@ class ModuleAndPackageDocumentationTransformerUnitTest { fun `single module documentation`() { val transformer = ModuleAndPackageDocumentationTransformer( object : ModuleAndPackageDocumentationReader { - override fun get(pkg: DPackage): SourceSetDependent<DocumentationNode> = throw NotImplementedError() - override fun get(module: DModule): SourceSetDependent<DocumentationNode> { + override fun read(pkg: DPackage): SourceSetDependent<DocumentationNode> = throw NotImplementedError() + override fun read(module: DModule): SourceSetDependent<DocumentationNode> { return module.sourceSets.associateWith { sourceSet -> documentationNode("doc" + sourceSet.displayName) } } - + override fun read(module: DokkaConfiguration.DokkaModuleDescription): DocumentationNode = throw NotImplementedError() } ) @@ -77,13 +83,14 @@ class ModuleAndPackageDocumentationTransformerUnitTest { fun `merges with already existing module documentation`() { val transformer = ModuleAndPackageDocumentationTransformer( object : ModuleAndPackageDocumentationReader { - override fun get(pkg: DPackage): SourceSetDependent<DocumentationNode> = throw NotImplementedError() - override fun get(module: DModule): SourceSetDependent<DocumentationNode> { + override fun read(pkg: DPackage): SourceSetDependent<DocumentationNode> = throw NotImplementedError() + override fun read(module: DModule): SourceSetDependent<DocumentationNode> { /* Only add documentation for first source set */ return module.sourceSets.take(1).associateWith { sourceSet -> documentationNode("doc" + sourceSet.displayName) } } + override fun read(module: DokkaConfiguration.DokkaModuleDescription): DocumentationNode = throw NotImplementedError() } ) @@ -121,8 +128,8 @@ class ModuleAndPackageDocumentationTransformerUnitTest { fun `package documentation`() { val transformer = ModuleAndPackageDocumentationTransformer( object : ModuleAndPackageDocumentationReader { - override fun get(module: DModule): SourceSetDependent<DocumentationNode> = emptyMap() - override fun get(pkg: DPackage): SourceSetDependent<DocumentationNode> { + override fun read(module: DModule): SourceSetDependent<DocumentationNode> = emptyMap() + override fun read(pkg: DPackage): SourceSetDependent<DocumentationNode> { /* Only attach documentation to packages with 'attach' */ if ("attach" !in pkg.dri.packageName.orEmpty()) return emptyMap() /* Only attach documentation to two source sets */ @@ -130,6 +137,7 @@ class ModuleAndPackageDocumentationTransformerUnitTest { documentationNode("doc:${sourceSet.displayName}:${pkg.dri.packageName}") } } + override fun read(module: DokkaConfiguration.DokkaModuleDescription): DocumentationNode = throw NotImplementedError() } ) @@ -239,4 +247,10 @@ class ModuleAndPackageDocumentationTransformerUnitTest { ) } + + private fun documentationNode(vararg texts: String): DocumentationNode { + return DocumentationNode( + texts.toList() + .map { Description(CustomDocTag(listOf(Text(it)), name = MARKDOWN_ELEMENT_FILE_NAME)) }) + } } |