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 | |
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')
11 files changed, 60 insertions, 143 deletions
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt index 952780c7..25400ca5 100644 --- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt +++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt @@ -26,9 +26,9 @@ class LinkableContentTest : AbstractCoreTest() { val includesDir = getTestDataDir("linkable/includes").toAbsolutePath() val configuration = dokkaConfiguration { + moduleName = "example" sourceSets { sourceSet { - moduleName = "example" analysisPlatform = "js" sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map { Paths.get("$testDataDir/$it/kotlin").toString() @@ -37,7 +37,6 @@ class LinkableContentTest : AbstractCoreTest() { includes = listOf(Paths.get("$includesDir/include2.md").toString()) } sourceSet { - moduleName = "example" analysisPlatform = "jvm" sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map { Paths.get("$testDataDir/$it/kotlin").toString() @@ -65,9 +64,10 @@ class LinkableContentTest : AbstractCoreTest() { val testDataDir = getTestDataDir("linkable/sources").toAbsolutePath() val configuration = dokkaConfiguration { + moduleName = "example" + sourceSets { sourceSet { - moduleName = "example" analysisPlatform = "js" sourceRoots = listOf("$testDataDir/jsMain/kotlin") sourceLinks = listOf( @@ -80,7 +80,6 @@ class LinkableContentTest : AbstractCoreTest() { name = "js" } sourceSet { - moduleName = "example" analysisPlatform = "jvm" sourceRoots = listOf("$testDataDir/jvmMain/kotlin") sourceLinks = listOf( @@ -130,16 +129,15 @@ class LinkableContentTest : AbstractCoreTest() { val testDataDir = getTestDataDir("linkable/samples").toAbsolutePath() val configuration = dokkaConfiguration { + moduleName = "example" sourceSets { sourceSet { - moduleName = "example" analysisPlatform = "js" sourceRoots = listOf("$testDataDir/jsMain/kotlin") name = "js" samples = listOf("$testDataDir/jsMain/resources/Samples.kt") } sourceSet { - moduleName = "example" analysisPlatform = "jvm" sourceRoots = listOf("$testDataDir/jvmMain/kotlin") name = "jvm" diff --git a/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt b/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt index 17f9631a..a2c2f97d 100644 --- a/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt +++ b/plugins/base/src/test/kotlin/parsers/ParseModuleAndPackageDocumentationFragmentsTest.kt @@ -98,20 +98,29 @@ class ParseModuleAndPackageDocumentationFragmentsTest { } @Test - fun `white space in module name fails`() { - val exception = assertThrows<IllegalModuleAndPackageDocumentation> { - parseModuleAndPackageDocumentationFragments( - source( - """ - # Module My Module - """.trimIndent() - ) + fun `white space in module name is supported`() { + val fragment = parseModuleAndPackageDocumentationFragments( + source( + """ + # Module My Module + Documentation for my module + """.trimIndent() ) - } + ) - assertTrue( - "Module My Module" in exception.message.orEmpty(), - "Expected problematic statement in error message" + assertEquals( + Module, fragment.single().classifier, + "Expected module being parsec" + ) + + assertEquals( + "My Module", fragment.single().name, + "Expected module name with white spaces being parsed" + ) + + assertEquals( + "Documentation for my module", fragment.single().documentation, + "Expected documentation being available" ) } diff --git a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt index 4f55695d..8426923d 100644 --- a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt +++ b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt @@ -21,14 +21,12 @@ import java.io.File abstract class HtmlRenderingOnlyTestBase : RenderingOnlyTestBase<Element>() { protected val js = defaultSourceSet.copy( - "root", "JS", defaultSourceSet.sourceSetID.copy(sourceSetName = "js"), analysisPlatform = Platform.js, sourceRoots = setOf(File("pl1")) ) protected val jvm = defaultSourceSet.copy( - "root", "JVM", defaultSourceSet.sourceSetID.copy(sourceSetName = "jvm"), @@ -36,7 +34,6 @@ abstract class HtmlRenderingOnlyTestBase : RenderingOnlyTestBase<Element>() { sourceRoots = setOf(File("pl1")) ) protected val native = defaultSourceSet.copy( - "root", "NATIVE", defaultSourceSet.sourceSetID.copy(sourceSetName = "native"), analysisPlatform = Platform.native, diff --git a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt index 77ba390e..4fd349e4 100644 --- a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt @@ -14,21 +14,18 @@ import java.io.File class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() { private val pl1 = defaultSourceSet.copy( - "root", "pl1", defaultSourceSet.sourceSetID.copy(sourceSetName = "pl1"), analysisPlatform = Platform.js, sourceRoots = setOf(File("pl1")) ) private val pl2 = defaultSourceSet.copy( - "root", "pl2", defaultSourceSet.sourceSetID.copy(sourceSetName = "pl2"), analysisPlatform = Platform.jvm, sourceRoots = setOf(File("pl1")) ) private val pl3 = defaultSourceSet.copy( - "root", "pl3", defaultSourceSet.sourceSetID.copy(sourceSetName = "pl3"), analysisPlatform = Platform.native, diff --git a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt index 7635ab05..2e8e0ef3 100644 --- a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt @@ -16,9 +16,9 @@ class DivergentSignatureTest : AbstractCoreTest() { val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() val configuration = dokkaConfiguration { + moduleName = "example" sourceSets { sourceSet { - moduleName = "example" displayName = "js" name = "js" analysisPlatform = "js" @@ -27,7 +27,6 @@ class DivergentSignatureTest : AbstractCoreTest() { } } sourceSet { - moduleName = "example" displayName = "jvm" name = "jvm" analysisPlatform = "jvm" @@ -36,7 +35,6 @@ class DivergentSignatureTest : AbstractCoreTest() { } } sourceSet { - moduleName = "example" displayName = "common" name = "common" analysisPlatform = "common" @@ -68,9 +66,9 @@ class DivergentSignatureTest : AbstractCoreTest() { val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() val configuration = dokkaConfiguration { + moduleName = "example" sourceSets { sourceSet { - moduleName = "example" displayName = "js" name = "js" analysisPlatform = "js" @@ -79,7 +77,6 @@ class DivergentSignatureTest : AbstractCoreTest() { } } sourceSet { - moduleName = "example" displayName = "jvm" name = "jvm" analysisPlatform = "jvm" @@ -88,7 +85,6 @@ class DivergentSignatureTest : AbstractCoreTest() { } } sourceSet { - moduleName = "example" displayName = "common" name = "common" analysisPlatform = "common" @@ -120,9 +116,9 @@ class DivergentSignatureTest : AbstractCoreTest() { val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() val configuration = dokkaConfiguration { + moduleName = "example" sourceSets { sourceSet { - moduleName = "example" displayName = "js" name = "js" analysisPlatform = "js" @@ -131,7 +127,6 @@ class DivergentSignatureTest : AbstractCoreTest() { } } sourceSet { - moduleName = "example" displayName = "jvm" name = "jvm" analysisPlatform = "jvm" @@ -140,7 +135,6 @@ class DivergentSignatureTest : AbstractCoreTest() { } } sourceSet { - moduleName = "example" displayName = "common" name = "common" analysisPlatform = "common" @@ -172,4 +166,4 @@ class DivergentSignatureTest : AbstractCoreTest() { private val Element.brief: String get() = children().select(".brief-with-platform-tags").text() -}
\ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index 1c3842c4..5a4b614f 100644 --- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt @@ -329,16 +329,15 @@ class SignatureTest : AbstractCoreTest() { fun `type with an actual typealias`() { val configuration = dokkaConfiguration { + moduleName = "test" sourceSets { sourceSet { - moduleName = "test" name = "common" sourceRoots = listOf("src/main/kotlin/common/Test.kt") classpath = listOf(commonStdlibPath!!) externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) } sourceSet { - moduleName = "test" name = "jvm" dependentSourceSets = setOf(DokkaSourceSetID("test", "common")) sourceRoots = listOf("src/main/kotlin/jvm/Test.kt") 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" |