diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-27 15:50:40 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-31 15:10:04 +0200 |
commit | 8cd28416817dfd7d28bb66b28e849d97cc09012b (patch) | |
tree | 962f9420f3ccdb47d6847c9e5a16d00018c9110c /plugins/base/src/test/kotlin/transformers | |
parent | 732d181e4908ed0ddc513e305addc71560c0e109 (diff) | |
download | dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.tar.gz dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.tar.bz2 dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.zip |
Let module name be configurable withing `AbstractDokkaTask` and remove concept of `moduleDisplayName`
Diffstat (limited to 'plugins/base/src/test/kotlin/transformers')
5 files changed, 30 insertions, 107 deletions
diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt index e04e751c..51a5e85a 100644 --- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt +++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt @@ -12,13 +12,11 @@ import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import testApi.testRunner.dokkaConfiguration -import testApi.testRunner.sourceSet +import testApi.testRunner.TestDokkaConfigurationBuilder class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAndPackageDocumentationReaderTest() { - private val includeSourceSetA by lazy { temporaryDirectory.resolve("includeA.md").toFile() } private val includeSourceSetB by lazy { temporaryDirectory.resolve("includeB.md").toFile() } @@ -51,40 +49,31 @@ class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAnd ) } - private val sourceSetA by lazy { - sourceSet { - moduleName = "moduleA" - name = "sourceSetA" - includes = listOf(includeSourceSetA.canonicalPath) - } + private val configurationBuilder = TestDokkaConfigurationBuilder().apply { + moduleName = "moduleA" } - private val sourceSetB by lazy { - sourceSet { - moduleName = "moduleB" - name = "sourceSetB" - includes = listOf(includeSourceSetB.canonicalPath) - } + private val sourceSetA by configurationBuilder.sourceSet { + name = "sourceSetA" + includes = listOf(includeSourceSetA.canonicalPath) } - private val sourceSetB2 by lazy { - sourceSet { - moduleName = "moduleB" - name = "sourceSetB2" - includes = emptyList() - } + + private val sourceSetB by configurationBuilder.sourceSet { + name = "sourceSetB" + includes = listOf(includeSourceSetB.canonicalPath) + } + + + private val sourceSetB2 by configurationBuilder.sourceSet { + name = "sourceSetB2" + includes = emptyList() } private val context by lazy { DokkaContext.create( - configuration = dokkaConfiguration { - sourceSets { - add(sourceSetA) - add(sourceSetB) - add(sourceSetB2) - } - }, + configuration = configurationBuilder.build(), logger = TestLogger(DokkaConsoleLogger), pluginOverrides = emptyList() ) @@ -121,7 +110,9 @@ class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAnd @Test fun `assert moduleA with unknown source set`() { - val documentation = reader[DModule("moduleA", sourceSets = setOf(sourceSet { name = "unknown" }))] + val documentation = reader[ + DModule("moduleA", sourceSets = setOf(configurationBuilder.unattachedSourceSet { name = "unknown" })) + ] assertEquals( emptyMap<DokkaSourceSet, DocumentationNode>(), documentation, "Expected no documentation received for module with unknown sourceSet" diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest2.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest2.kt deleted file mode 100644 index e209a170..00000000 --- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest2.kt +++ /dev/null @@ -1,63 +0,0 @@ -package transformers - -import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationReader -import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.utilities.DokkaConsoleLogger -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import testApi.testRunner.dokkaConfiguration -import testApi.testRunner.sourceSet - - -class ContextModuleAndPackageDocumentationReaderTest2: AbstractContextModuleAndPackageDocumentationReaderTest() { - - private val include by lazy { temporaryDirectory.resolve("include.md").toFile() } - - @BeforeEach - fun materializeInclude() { - include.writeText( - """ - # Module MyModuleDisplayName - Matching: moduleDisplayName - - # Module myModuleName - Matching: moduleName - """.trimIndent() - ) - } - - private val sourceSet by lazy { - sourceSet { - moduleName = "myModuleName" - moduleDisplayName = "MyModuleDisplayName" - includes = listOf(include.canonicalPath) - } - } - - private val context by lazy { - DokkaContext.create( - configuration = dokkaConfiguration { - sourceSets { - add(sourceSet) - } - }, - logger = DokkaConsoleLogger, - pluginOverrides = emptyList() - ) - } - - private val reader by lazy { ModuleAndPackageDocumentationReader(context) } - - - @Test - fun `module matches for moduleName and moduleDisplayName`() { - val documentation = reader[DModule("myModuleName", sourceSets = setOf(sourceSet))] - assertEquals(1, documentation.keys.size, "Expected only one entry from sourceSet") - assertEquals(sourceSet, documentation.keys.single(), "Expected only one entry from sourceSet") - assertEquals( - listOf("Matching: moduleDisplayName", "Matching: moduleName"), documentation.texts - ) - } -} diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt index e1b9d199..a557379b 100644 --- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt +++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt @@ -7,6 +7,7 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import testApi.testRunner.TestDokkaConfigurationBuilder import testApi.testRunner.dokkaConfiguration import testApi.testRunner.sourceSet import kotlin.test.assertEquals @@ -28,19 +29,15 @@ class ContextModuleAndPackageDocumentationReaderTest3 : AbstractContextModuleAnd ) } - private val sourceSet by lazy { - sourceSet { - includes = listOf(include.canonicalPath) - } + private val configurationBuilder = TestDokkaConfigurationBuilder() + + private val sourceSet by configurationBuilder.sourceSet { + includes = listOf(include.canonicalPath) } private val context by lazy { DokkaContext.create( - configuration = dokkaConfiguration { - sourceSets { - add(sourceSet) - } - }, + configuration = configurationBuilder.build(), logger = DokkaConsoleLogger, pluginOverrides = emptyList() ) diff --git a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt index 2d356a81..68e41ad1 100644 --- a/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt @@ -35,9 +35,9 @@ class ModuleAndPackageDocumentationTransformerFunctionalTest : AbstractCoreTest( """.trimIndent() ) val configuration = dokkaConfiguration { + moduleName = "moduleA" sourceSets { sourceSet { - moduleName = "moduleA" name = "commonMain" displayName = "common" analysisPlatform = "common" @@ -45,7 +45,6 @@ class ModuleAndPackageDocumentationTransformerFunctionalTest : AbstractCoreTest( includes = listOf(include.canonicalPath) } sourceSet { - moduleName = "moduleA" name = "jsMain" displayName = "js" analysisPlatform = "js" @@ -54,7 +53,6 @@ class ModuleAndPackageDocumentationTransformerFunctionalTest : AbstractCoreTest( includes = listOf(include.canonicalPath) } sourceSet { - moduleName = "moduleA" name = "jvmMain" displayName = "jvm" analysisPlatform = "jvm" diff --git a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt index 72948372..265baa42 100644 --- a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt @@ -484,7 +484,7 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { fun `multiplatform undocumented class gets reported`() { val configuration = dokkaConfiguration { sourceSets { - val commonMain = sourceSet { + val commonMain by sourceSet { reportUndocumented = true analysisPlatform = Platform.common.toString() name = "commonMain" @@ -527,7 +527,7 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { fun `multiplatform undocumented class does not get reported if expect is documented`() { val configuration = dokkaConfiguration { sourceSets { - val commonMain = sourceSet { + val commonMain by sourceSet { reportUndocumented = true analysisPlatform = Platform.common.toString() name = "commonMain" @@ -569,7 +569,7 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { fun `multiplatform undocumented function gets reported`() { val configuration = dokkaConfiguration { sourceSets { - val commonMain = sourceSet { + val commonMain by sourceSet { reportUndocumented = true analysisPlatform = Platform.common.toString() name = "commonMain" |