diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-26 11:47:49 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-31 15:10:04 +0200 |
commit | ee13af00483887fb6cfdde10a58cbb43542cf2d7 (patch) | |
tree | f8af0819f34e4188e3d3800b818efb864e623068 /plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerTest.kt | |
parent | 8d25036f5b919e9d3acc8907e70e965330efae82 (diff) | |
download | dokka-ee13af00483887fb6cfdde10a58cbb43542cf2d7.tar.gz dokka-ee13af00483887fb6cfdde10a58cbb43542cf2d7.tar.bz2 dokka-ee13af00483887fb6cfdde10a58cbb43542cf2d7.zip |
Implement tests for ModuleAndPackageDocumentationReader
Diffstat (limited to 'plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerTest.kt')
-rw-r--r-- | plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerTest.kt | 59 |
1 files changed, 15 insertions, 44 deletions
diff --git a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerTest.kt index a947633d..d2b41273 100644 --- a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerTest.kt @@ -1,18 +1,16 @@ package transformers -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationReader 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.Description import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.model.doc.Text import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import renderers.defaultSourceSet +import testApi.testRunner.documentationNode +import testApi.testRunner.sourceSet class ModuleAndPackageDocumentationTransformerTest { @@ -141,22 +139,22 @@ class ModuleAndPackageDocumentationTransformerTest { documentation = emptyMap(), sourceSets = emptySet(), packages = listOf( - dPackage( - name = "com.sample", + DPackage( + dri = DRI("com.sample"), documentation = mapOf( sourceSet("A") to documentationNode("pre-existing:A:com.sample") ), sourceSets = setOf(sourceSet("A"), sourceSet("B"), sourceSet("C")), ), - dPackage( - name = "com.attach", + DPackage( + dri = DRI("com.attach"), documentation = mapOf( sourceSet("A") to documentationNode("pre-existing:A:com.attach") ), sourceSets = setOf(sourceSet("A"), sourceSet("B"), sourceSet("C")) ), - dPackage( - name = "com.attach.sub", + DPackage( + dri = DRI("com.attach.sub"), documentation = mapOf( sourceSet("A") to documentationNode("pre-existing:A:com.attach.sub"), sourceSet("B") to documentationNode("pre-existing:B:com.attach.sub"), @@ -178,7 +176,7 @@ class ModuleAndPackageDocumentationTransformerTest { val comSample = result.single().packages.single { it.dri.packageName == "com.sample" } assertEquals( - mapOf(sourceSet("A") to documentationNode("pre-existing:A:com.sample")), + mapOf(sourceSet("A") to documentationNode("pre-existing:A:com.sample")), comSample.documentation, "Expected no documentation added to package 'com.sample' because of wrong package" ) @@ -199,8 +197,8 @@ class ModuleAndPackageDocumentationTransformerTest { documentation = emptyMap(), sourceSets = emptySet(), packages = listOf( - dPackage( - name = "com.sample", + DPackage( + dri = DRI("com.sample"), documentation = mapOf( /* No documentation added, since in wrong package */ sourceSet("A") to documentationNode("pre-existing:A:com.sample") @@ -208,8 +206,8 @@ class ModuleAndPackageDocumentationTransformerTest { sourceSets = setOf(sourceSet("A"), sourceSet("B"), sourceSet("C")), ), - dPackage( - name = "com.attach", + DPackage( + dri = DRI("com.attach"), documentation = mapOf( /* Documentation added */ sourceSet("A") to documentationNode("pre-existing:A:com.attach", "doc:A:com.attach"), @@ -217,8 +215,8 @@ class ModuleAndPackageDocumentationTransformerTest { ), sourceSets = setOf(sourceSet("A"), sourceSet("B"), sourceSet("C")), ), - dPackage( - name = "com.attach.sub", + DPackage( + dri = DRI("com.attach.sub"), documentation = mapOf( /* Documentation added */ sourceSet("A") to documentationNode( @@ -241,30 +239,3 @@ class ModuleAndPackageDocumentationTransformerTest { } } - - -private fun sourceSet(name: String): DokkaSourceSet { - return defaultSourceSet.copy( - displayName = name, - sourceSetID = defaultSourceSet.sourceSetID.copy(sourceSetName = name) - ) -} - -private fun documentationNode(vararg texts: String): DocumentationNode { - return DocumentationNode(texts.toList().map { Description(Text(it)) }) -} - -private fun dPackage( - name: String, - documentation: SourceSetDependent<DocumentationNode>, - sourceSets: Set<DokkaSourceSet> -): DPackage = DPackage( - dri = DRI(name), - documentation = documentation, - sourceSets = sourceSets, - classlikes = emptyList(), - functions = emptyList(), - properties = emptyList(), - typealiases = emptyList() - -) |