diff options
Diffstat (limited to 'plugins')
22 files changed, 104 insertions, 184 deletions
diff --git a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt index d1832cbc..a87d4319 100644 --- a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt +++ b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt @@ -16,7 +16,6 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.transformers.pages.PageCreator import org.jetbrains.dokka.utilities.DokkaLogger -import java.io.File class MultimodulePageCreator( val context: DokkaContext diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt index 6155af52..e66b7612 100644 --- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt +++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt @@ -37,9 +37,9 @@ private fun parseModuleAndPackageDocFragment( } val name = classifierAndName.getOrNull(1)?.trim().orEmpty() - if (name.contains(Regex("\\s"))) { + if (classifier == Package && name.contains(Regex("\\s"))) { throw IllegalModuleAndPackageDocumentation( - source, "Module/Package name cannot contain whitespace in '$firstLine'" + source, "Package name cannot contain whitespace in '$firstLine'" ) } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index c8e4f565..17ead667 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -10,20 +10,15 @@ internal object DefaultDocumentableMerger : DocumentableMerger { override fun invoke(modules: Collection<DModule>, context: DokkaContext): DModule { - val projectName = - modules.fold(modules.first().name) { acc, module -> acc.commonPrefixWith(module.name) } - .takeIf { it.isNotEmpty() } - ?: "project" - return modules.reduce { left, right -> val list = listOf(left, right) DModule( - name = projectName, + name = modules.map { it.name }.distinct().joinToString("|"), packages = merge( list.flatMap { it.packages }, DPackage::mergeWith ), - documentation = list.map { it.documentation }.flatMap { it.entries }.associate { (k,v) -> k to v }, + documentation = list.map { it.documentation }.flatMap { it.entries }.associate { (k, v) -> k to v }, expectPresentInSet = list.firstNotNullResult { it.expectPresentInSet }, sourceSets = list.flatMap { it.sourceSets }.toSet() ).mergeExtras(left, right) @@ -61,7 +56,7 @@ fun DFunction.mergeWith(other: DFunction): DFunction = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, modifier = modifier + other.modifier, sourceSets = sourceSets + other.sourceSets, @@ -72,7 +67,7 @@ fun DProperty.mergeWith(other: DProperty): DProperty = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, modifier = modifier + other.modifier, sourceSets = sourceSets + other.sourceSets, @@ -104,7 +99,7 @@ fun DClass.mergeWith(other: DClass): DClass = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -122,7 +117,7 @@ fun DEnum.mergeWith(other: DEnum): DEnum = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -143,7 +138,7 @@ fun DObject.mergeWith(other: DObject): DObject = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -157,7 +152,7 @@ fun DInterface.mergeWith(other: DInterface): DInterface = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -173,7 +168,7 @@ fun DAnnotation.mergeWith(other: DAnnotation): DAnnotation = copy( companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets, generics = merge(generics + other.generics, DTypeParameter::mergeWith) @@ -197,4 +192,4 @@ fun DTypeAlias.mergeWith(other: DTypeAlias): DTypeAlias = copy( underlyingType = underlyingType + other.underlyingType, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets -).mergeExtras(this, other)
\ No newline at end of file +).mergeExtras(this, other) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt index 66156832..6a6231c5 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt @@ -249,4 +249,4 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe } } } -}
\ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt index e712d6e5..e126d05f 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt @@ -65,11 +65,7 @@ private class ContextModuleAndPackageDocumentationReader( override fun get(module: DModule): SourceSetDependent<DocumentationNode> { return findDocumentationNodes(module.sourceSets) { fragment -> - fragment.classifier == Classifier.Module && ( - /* Match fragment name against module name or distinct module displayName */ - fragment.name == module.name || - fragment.name == module.sourceSets.map { it.moduleDisplayName }.distinct().singleOrNull() - ) + fragment.classifier == Classifier.Module && (fragment.name == module.name) } } diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt index 2099cab5..ca239d83 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt @@ -62,12 +62,12 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { private fun ContentNode.addSample( contentPage: ContentPage, - platform: DokkaSourceSet, + sourceSet: DokkaSourceSet, fqName: String, analysis: Map<DokkaSourceSet, EnvironmentAndFacade> ): ContentNode { - val facade = analysis[platform]?.facade - ?: return this.also { context.logger.warn("Cannot resolve facade for platform ${platform.moduleDisplayName}") } + val facade = analysis[sourceSet]?.facade + ?: return this.also { context.logger.warn("Cannot resolve facade for platform ${sourceSet.sourceSetID}") } val psiElement = fqNameToPsiElement(facade, fqName) ?: return this.also { context.logger.warn("Cannot find PsiElement corresponding to $fqName") } val imports = diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 18b05df4..8e5a1927 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -70,7 +70,15 @@ class DefaultDescriptorToDocumentableTranslator( DRIWithPlatformInfo(DRI.topLevel, emptyMap()) ) } - }.let { DModule(sourceSet.moduleDisplayName, it, emptyMap(), null, setOf(sourceSet)) } + }.let { + DModule( + name = context.configuration.moduleName, + packages = it, + documentation = emptyMap(), + expectPresentInSet = null, + sourceSets = setOf(sourceSet) + ) + } } } @@ -557,7 +565,9 @@ private class DokkaDescriptorVisitor( private fun ClassDescriptor.resolveClassDescriptionData(): ClassInfo { fun toTypeConstructor(kt: KotlinType) = - TypeConstructor(DRI.from(kt.constructor.declarationDescriptor as DeclarationDescriptor), kt.arguments.map { it.toProjection() }) + TypeConstructor( + DRI.from(kt.constructor.declarationDescriptor as DeclarationDescriptor), + kt.arguments.map { it.toProjection() }) tailrec fun buildAncestryInformation( supertypes: Collection<KotlinType>, @@ -753,13 +763,22 @@ private class DokkaDescriptorVisitor( private fun ValueArgument.childrenAsText() = this.safeAs<KtValueArgument>()?.children?.map { it.text }.orEmpty() - private data class AncestryLevel(val level: Int, val superclass: TypeConstructor?, val interfaces: List<TypeConstructor>) + private data class AncestryLevel( + val level: Int, + val superclass: TypeConstructor?, + val interfaces: List<TypeConstructor> + ) - private data class ClassInfo(val ancestry: List<AncestryLevel>, val docs: SourceSetDependent<DocumentationNode>){ + private data class ClassInfo(val ancestry: List<AncestryLevel>, val docs: SourceSetDependent<DocumentationNode>) { val supertypes: List<TypeConstructorWithKind> get() = ancestry.firstOrNull { it.level == 0 }?.let { - listOfNotNull(it.superclass?.let { TypeConstructorWithKind(it, KotlinClassKindTypes.CLASS) }) + it.interfaces.map { TypeConstructorWithKind(it, KotlinClassKindTypes.INTERFACE) } - }.orEmpty() + listOfNotNull(it.superclass?.let { + TypeConstructorWithKind( + it, + KotlinClassKindTypes.CLASS + ) + }) + it.interfaces.map { TypeConstructorWithKind(it, KotlinClassKindTypes.INTERFACE) } + }.orEmpty() val allImplementedInterfaces: List<TypeConstructor> get() = ancestry.flatMap { it.interfaces }.distinct() diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index c1ed4a08..30e46404 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -68,7 +68,7 @@ class DefaultPsiToDocumentableTranslator( context.logger ) return DModule( - sourceSet.moduleDisplayName, + context.configuration.moduleName, psiFiles.mapNotNull { it.safeAs<PsiJavaFile>() }.groupBy { it.packageName }.map { (packageName, psiFiles) -> val dri = DRI(packageName = packageName) DPackage( 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" diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt index cd9b9dfc..dee43b1d 100644 --- a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt +++ b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt @@ -12,21 +12,18 @@ import java.io.File class DivergentTest : GfmRenderingOnlyTestBase() { private val js = defaultSourceSet.copy( - "root", "js", DokkaSourceSetID("root", "js"), analysisPlatform = Platform.js, sourceRoots = setOf(File("pl1")) ) private val jvm = defaultSourceSet.copy( - "root", "jvm", DokkaSourceSetID("root", "jvm"), analysisPlatform = Platform.jvm, sourceRoots = setOf(File("pl1")) ) private val native = defaultSourceSet.copy( - "root", "native", DokkaSourceSetID("root", "native"), analysisPlatform = Platform.native, diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt index 35c2da3d..a118a20e 100644 --- a/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt +++ b/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt @@ -21,7 +21,7 @@ abstract class GfmRenderingOnlyTestBase : RenderingOnlyTestBase<String>() { DokkaBase().externalLocationProviderFactory to { ::DefaultExternalLocationProviderFactory }, GfmPlugin().gfmPreprocessors to { _ -> RootCreator }, - testConfiguration = DokkaConfigurationImpl() + testConfiguration = DokkaConfigurationImpl(moduleName = "root") ) override val renderedContent: String by lazy { diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt index de473db0..93edd001 100644 --- a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt +++ b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt @@ -12,21 +12,18 @@ import java.io.File class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { private val pl1 = defaultSourceSet.copy( - "root", "pl1", DokkaSourceSetID("root", "pl1"), analysisPlatform = Platform.js, sourceRoots = setOf(File("pl1")) ) private val pl2 = defaultSourceSet.copy( - "root", "pl2", DokkaSourceSetID("root", "pl2"), analysisPlatform = Platform.jvm, sourceRoots = setOf(File("pl1")) ) private val pl3 = defaultSourceSet.copy( - "root", "pl3", DokkaSourceSetID("root", "pl3"), analysisPlatform = Platform.native, |