diff options
52 files changed, 246 insertions, 325 deletions
@@ -141,7 +141,6 @@ dokkaHtml { cacheRoot.set(file("default")) dokkaSourceSets { configureEach { // Or source set name, for single-platform the default source sets are `main` and `test` - moduleDisplayName.set("data") // Used when configuring source sets manually for declaring which source sets this one depends on dependsOn("otherSourceSetName") @@ -407,7 +406,7 @@ The available configuration options are shown below: <skip>false</skip> <!-- Default: ${project.artifactId} --> - <moduleDisplayName>data</moduleDisplayName> + <moduleName>data</moduleName> <!-- Default: ${project.basedir}/target/dokka --> <outputDir>some/out/dir</outputDir> @@ -556,7 +555,6 @@ Dokka supports the following command line arguments: * `-globalSrcLink` - source links added to all source sets * `-sourceSet` - (repeatable) - configuration for a single source set. Following this argument, you can pass other arguments: * `-moduleName` - (required) - module name used as a part of source set ID when declaring dependent source sets - * `-moduleDisplayName` - displayed module name * `-sourceSetName` - source set name as a part of source set ID when declaring dependent source sets * `-displayName` - source set name displayed in the generated documentation * `-src` - list of source files or directories separated by `;` diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index 2aa252e1..9a1ff602 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -9,6 +9,7 @@ import java.io.Serializable import java.net.URL object DokkaDefaults { + val moduleName: String = "root" val outputDir = File("./dokka") const val format: String = "html" val cacheRoot: File? = null @@ -58,12 +59,13 @@ interface DokkaConfigurationBuilder<T : Any> { fun <T : Any> Iterable<DokkaConfigurationBuilder<T>>.build(): List<T> = this.map { it.build() } + data class DokkaSourceSetID( - val moduleName: String, + val scopeId: String, val sourceSetName: String ) : Serializable { override fun toString(): String { - return "$moduleName/$sourceSetName" + return "$scopeId/$sourceSetName" } } @@ -72,6 +74,7 @@ fun DokkaConfigurationImpl(json: String): DokkaConfigurationImpl = parseJson(jso fun DokkaConfiguration.toJsonString(): String = toJsonString(this) interface DokkaConfiguration : Serializable { + val moduleName: String val outputDir: File val cacheRoot: File? val offlineMode: Boolean @@ -84,7 +87,6 @@ interface DokkaConfiguration : Serializable { interface DokkaSourceSet : Serializable { val sourceSetID: DokkaSourceSetID val displayName: String - val moduleDisplayName: String val classpath: List<File> val sourceRoots: Set<File> val dependentSourceSets: Set<DokkaSourceSetID> diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index 8bd2d976..3fcc7aac 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -5,6 +5,7 @@ import java.io.File import java.net.URL data class DokkaConfigurationImpl( + override val moduleName: String = DokkaDefaults.moduleName, override val outputDir: File = DokkaDefaults.outputDir, override val cacheRoot: File? = DokkaDefaults.cacheRoot, override val offlineMode: Boolean = DokkaDefaults.offlineMode, @@ -12,12 +13,11 @@ data class DokkaConfigurationImpl( override val pluginsClasspath: List<File> = emptyList(), override val pluginsConfiguration: Map<String, String> = emptyMap(), override val modules: List<DokkaModuleDescriptionImpl> = emptyList(), - override val failOnWarning: Boolean = DokkaDefaults.failOnWarning + override val failOnWarning: Boolean = DokkaDefaults.failOnWarning, ) : DokkaConfiguration data class DokkaSourceSetImpl( - override val moduleDisplayName: String, override val displayName: String = DokkaDefaults.sourceSetDisplayName, override val sourceSetID: DokkaSourceSetID, override val classpath: List<File> = emptyList(), diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt index 3c1cf7de..9f38dafb 100644 --- a/core/src/main/kotlin/model/CompositeSourceSetID.kt +++ b/core/src/main/kotlin/model/CompositeSourceSetID.kt @@ -14,7 +14,7 @@ data class CompositeSourceSetID( } val merged = DokkaSourceSetID( - moduleName = children.map { it.moduleName }.reduce { acc, s -> "$acc+$s" }, + scopeId = children.map { it.scopeId }.reduce { acc, s -> "$acc+$s" }, sourceSetName = children.map { it.sourceSetName }.reduce { acc, s -> "$acc+$s" } ) diff --git a/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt b/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt index 8efc84c6..ba33ab92 100644 --- a/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt +++ b/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt @@ -9,11 +9,11 @@ class DokkaConfigurationJsonTest { @Test fun `simple configuration toJsonString then parseJson`() { val configuration = DokkaConfigurationImpl( + moduleName = "moduleName", outputDir = File("customOutputDir"), pluginsClasspath = listOf(File("plugins/customPlugin.jar")), sourceSets = listOf( DokkaSourceSetImpl( - moduleDisplayName = "customModuleDisplayName", sourceRoots = setOf(File("customSourceRoot")), sourceSetID = DokkaSourceSetID("customModuleName", "customSourceSetName") ) @@ -29,13 +29,13 @@ class DokkaConfigurationJsonTest { fun `parse simple configuration json`() { val json = """ { + "moduleName": "moduleName", "outputDir": "customOutputDir", "pluginsClasspath": [ "plugins/customPlugin.jar" ], "sourceSets": [ { - "moduleDisplayName": "customModuleDisplayName", "sourceSetID": { - "moduleName": "customModuleName", + "scopeId": "customModuleName", "sourceSetName": "customSourceSetName" }, "sourceRoots": [ "customSourceRoot" ], @@ -48,11 +48,11 @@ class DokkaConfigurationJsonTest { val parsedConfiguration = DokkaConfigurationImpl(json) assertEquals( DokkaConfigurationImpl( + moduleName = "moduleName", outputDir = File("customOutputDir"), pluginsClasspath = listOf(File("plugins/customPlugin.jar")), sourceSets = listOf( DokkaSourceSetImpl( - moduleDisplayName = "customModuleDisplayName", sourceRoots = setOf(File("customSourceRoot")), sourceSetID = DokkaSourceSetID("customModuleName", "customSourceSetName"), classpath = listOf(File("classpath/custom1.jar"), File("classpath/custom2.jar")) diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt index 5bf7e52d..f6cb99db 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt @@ -16,6 +16,13 @@ annotation class DokkaConfigurationDsl @DokkaConfigurationDsl class TestDokkaConfigurationBuilder { + + var moduleName: String = "root" + set(value) { + check(lazySourceSets.isEmpty()) { "Cannot set moduleName after adding source sets" } + field = value + } + var outputDir: String = "out" var format: String = "html" var offlineMode: Boolean = false @@ -23,12 +30,13 @@ class TestDokkaConfigurationBuilder { var pluginsClasspath: List<File> = emptyList() var pluginsConfigurations: Map<String, String> = emptyMap() var failOnWarning: Boolean = false - private val sourceSets = mutableListOf<DokkaSourceSetImpl>() + private val lazySourceSets = mutableListOf<Lazy<DokkaSourceSetImpl>>() fun build() = DokkaConfigurationImpl( + moduleName = moduleName, outputDir = File(outputDir), cacheRoot = cacheRoot?.let(::File), offlineMode = offlineMode, - sourceSets = sourceSets.toList(), + sourceSets = lazySourceSets.map { it.value }.toList(), pluginsClasspath = pluginsClasspath, pluginsConfiguration = pluginsConfigurations, modules = emptyList(), @@ -36,28 +44,29 @@ class TestDokkaConfigurationBuilder { ) fun sourceSets(block: SourceSetsBuilder.() -> Unit) { - sourceSets.addAll(SourceSetsBuilder().apply(block)) + lazySourceSets.addAll(SourceSetsBuilder(moduleName).apply(block)) } - fun add(sourceSet: DokkaSourceSetImpl) { - sourceSets.add(sourceSet) + fun sourceSet(block: DokkaSourceSetBuilder.() -> Unit): Lazy<DokkaSourceSetImpl> { + val lazySourceSet = lazy { DokkaSourceSetBuilder(moduleName).apply(block).build() } + lazySourceSets.add(lazySourceSet) + return lazySourceSet } -} -@DokkaConfigurationDsl -class SourceSetsBuilder : ArrayList<DokkaSourceSetImpl>() { - fun sourceSet(block: DokkaSourceSetBuilder.() -> Unit): DokkaConfiguration.DokkaSourceSet = - DokkaSourceSetBuilder().apply(block).build().apply(::add) + fun unattachedSourceSet(block: DokkaSourceSetBuilder.() -> Unit): DokkaSourceSetImpl { + return DokkaSourceSetBuilder(moduleName).apply(block).build() + } } -fun sourceSet(block: DokkaSourceSetBuilder.() -> Unit): DokkaSourceSetImpl { - return DokkaSourceSetBuilder().apply(block).build() +@DokkaConfigurationDsl +class SourceSetsBuilder(val moduleName: String) : ArrayList<Lazy<DokkaSourceSetImpl>>() { + fun sourceSet(block: DokkaSourceSetBuilder.() -> Unit): Lazy<DokkaConfiguration.DokkaSourceSet> = + lazy { DokkaSourceSetBuilder(moduleName).apply(block).build() }.apply(::add) } @DokkaConfigurationDsl class DokkaSourceSetBuilder( - var moduleName: String = "root", - var moduleDisplayName: String? = null, + private val moduleName: String, var name: String = "main", var displayName: String = "JVM", var classpath: List<String> = emptyList(), @@ -81,7 +90,6 @@ class DokkaSourceSetBuilder( var sourceLinks: List<SourceLinkDefinitionImpl> = emptyList() ) { fun build() = DokkaSourceSetImpl( - moduleDisplayName = moduleDisplayName ?: moduleName, displayName = displayName, sourceSetID = DokkaSourceSetID(moduleName, name), classpath = classpath.map(::File), @@ -107,7 +115,6 @@ class DokkaSourceSetBuilder( } val defaultSourceSet = DokkaSourceSetImpl( - moduleDisplayName = "DEFAULT", displayName = "DEFAULT", sourceSetID = DokkaSourceSetID("DEFAULT", "DEFAULT"), classpath = emptyList(), diff --git a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt index 6510c044..aabc30c1 100644 --- a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt +++ b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt @@ -34,10 +34,9 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { "java", "-jar", cliJarFile.path, "-outputDir", dokkaOutputDir.path, "-pluginsClasspath", basePluginJarFile.path, + "-moduleName", "Basic Project", "-sourceSet", buildString { - append(" -moduleName it-cli") - append(" -moduleDisplayName CLI-Example") append(" -sourceSetName cliMain") append(" -src ${File(projectDir, "src").path}") append(" -jdkVersion 8") diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts index 21187561..2769677f 100644 --- a/integration-tests/gradle/projects/it-basic/build.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts @@ -15,9 +15,9 @@ dependencies { } tasks.withType<DokkaTask> { + moduleName.set("Basic Project") dokkaSourceSets { configureEach { - moduleDisplayName.set("Basic Project") suppressedFiles.from(file("src/main/kotlin/it/suppressedByPath")) perPackageOption { prefix.set("it.suppressedByPackage") diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt index 1265d675..f3bcfd59 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt @@ -84,7 +84,7 @@ class BasicGradleIntegrationTest(override val versions: BuildVersions) : Abstrac assertTrue( allHtmlFiles().any { file -> "Basic Project" in file.readText() }, - "Expected configured moduleDisplayName to be present in html" + "Expected configured moduleName to be present in html" ) assertTrue( diff --git a/integration-tests/maven/projects/it-maven/pom.xml b/integration-tests/maven/projects/it-maven/pom.xml index 350701f9..80620c82 100644 --- a/integration-tests/maven/projects/it-maven/pom.xml +++ b/integration-tests/maven/projects/it-maven/pom.xml @@ -91,7 +91,7 @@ <skip>false</skip> <!-- Default: ${project.artifactId} --> - <moduleDisplayName>Maven Integration Test Module</moduleDisplayName> + <moduleName>Maven Integration Test Module</moduleName> <!-- Default: ${project.basedir}/target/dokka --> <outputDir>${project.basedir}/output</outputDir> 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, diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 069ef166..9f7755f6 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -2,13 +2,11 @@ package org.jetbrains.dokka import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet.* import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.cast import java.io.* import java.net.MalformedURLException import java.net.URL -import java.nio.file.Files import java.nio.file.Paths class GlobalArguments(args: Array<String>) : DokkaConfiguration { @@ -17,6 +15,14 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { val json: String? by parser.argument(ArgType.String, description = "Json file name").optional() + private val _moduleName = parser.option( + ArgType.String, + description = "Name of the documentation module", + fullName = "moduleName" + ).required() + + override val moduleName: String by _moduleName + override val outputDir by parser.option(ArgTypeFile, description = "Output directory path") .default(DokkaDefaults.outputDir) @@ -26,7 +32,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { ) override val sourceSets by parser.option( - ArgTypeArgument, + ArgTypeArgument(_moduleName), description = "Single dokka source set", fullName = "sourceSet" ).multiple() @@ -68,7 +74,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { ).delimiter(";") val helpSourceSet by parser.option( - ArgTypeHelpSourceSet, + ArgTypeHelpSourceSet(_moduleName), description = "Prints help for single -sourceSet" ) @@ -103,21 +109,10 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { } } -private fun parseSourceSet(args: Array<String>): DokkaConfiguration.DokkaSourceSet { +private fun parseSourceSet(moduleName: String, args: Array<String>): DokkaConfiguration.DokkaSourceSet { val parser = ArgParser("sourceSet", prefixStyle = ArgParser.OptionPrefixStyle.JVM) - val moduleName by parser.option( - ArgType.String, - description = "Name of the documentation module", - fullName = "moduleName" - ).required() - - val moduleDisplayName by parser.option( - ArgType.String, - description = "Name of the documentation module" - ) - val sourceSetName by parser.option( ArgType.String, description = "Name of the source set" @@ -218,7 +213,6 @@ private fun parseSourceSet(args: Array<String>): DokkaConfiguration.DokkaSourceS parser.parse(args) return object : DokkaConfiguration.DokkaSourceSet { - override val moduleDisplayName = moduleDisplayName ?: moduleName override val displayName = displayName override val sourceSetID = DokkaSourceSetID(moduleName, sourceSetName) override val classpath = classpath.toMutableList() @@ -281,17 +275,20 @@ object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefini get() = "{ String that represent source links }" } -object ArgTypeArgument : ArgType<DokkaConfiguration.DokkaSourceSet>(true) { +data class ArgTypeArgument(val moduleName: CLIEntity<kotlin.String>) : + ArgType<DokkaConfiguration.DokkaSourceSet>(true) { override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet = - parseSourceSet(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) + parseSourceSet(moduleName.value, value.split(" ").filter { it.isNotBlank() }.toTypedArray()) override val description: kotlin.String get() = "" } // Workaround for printing nested parsers help -object ArgTypeHelpSourceSet : ArgType<Any>(false) { - override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { parseSourceSet(arrayOf("-h")) } +data class ArgTypeHelpSourceSet(val moduleName: CLIEntity<kotlin.String>) : ArgType<Any>(false) { + override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { + parseSourceSet(moduleName.value, arrayOf("-h")) + } override val description: kotlin.String get() = "" diff --git a/runners/gradle-plugin/MIGRATION.md b/runners/gradle-plugin/MIGRATION.md index 555ce66e..527c3e66 100644 --- a/runners/gradle-plugin/MIGRATION.md +++ b/runners/gradle-plugin/MIGRATION.md @@ -68,7 +68,7 @@ tasks.dokkaHtml.configure { #### Properties ```kotlin /* 0.10.x */ moduleName = "myModule" -/* 1.4.x */ moduleDisplayName.set("myModule") +/* 1.4.x */ /* Use AbstractDokkaTask#moduleName instead */ /* 0.10.x */ includeNonPublic = false /* 1.4.x */ includeNonPublic.set(false) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt index 89308e2a..b4800124 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt @@ -24,6 +24,10 @@ abstract class AbstractDokkaTask( private val bootstrapClass: KClass<out DokkaBootstrap> = DokkaBootstrap::class ) : DefaultTask() { + @Input + val moduleName: Property<String> = project.objects.safeProperty<String>() + .safeConvention(project.name) + @OutputDirectory val outputDirectory: Property<File> = project.objects.safeProperty<File>() .safeConvention(defaultDokkaOutputDirectory()) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt index 532e9e84..cd53398a 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt @@ -11,6 +11,7 @@ abstract class DokkaCollectorTask : AbstractDokkaParentTask() { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { val initialDokkaConfiguration = DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), failOnWarning = failOnWarning.getSafe(), diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt index 2e7b7490..82e2148f 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt @@ -3,6 +3,8 @@ package org.jetbrains.dokka.gradle import org.gradle.api.internal.tasks.TaskDependencyInternal import org.gradle.api.provider.Property import org.gradle.api.tasks.* +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.DokkaModuleDescriptionImpl import org.jetbrains.dokka.DokkaMultimoduleBootstrapImpl @@ -51,6 +53,7 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo } override fun buildDokkaConfiguration(): DokkaConfigurationImpl = DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), pluginsConfiguration = pluginsConfiguration.getSafe(), @@ -67,4 +70,3 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo ) } - diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt index d07873d8..beec3a7e 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt @@ -12,7 +12,7 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { @get:Internal val dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSetBuilder> = - project.container(GradleDokkaSourceSetBuilder::class.java, GradleDokkaSourceSetBuilderFactory()) + project.container(GradleDokkaSourceSetBuilder::class.java, gradleDokkaSourceSetBuilderFactory()) .also { container -> DslObject(this).extensions.add("dokkaSourceSets", container) project.kotlinOrNull?.sourceSets?.all { kotlinSourceSet -> @@ -36,6 +36,7 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { return DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), offlineMode = offlineMode.getSafe(), diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt index bb44eb52..d3a6c587 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt @@ -1,12 +1,10 @@ @file:Suppress("FunctionName", "UnstableApiUsage") +@file:JvmName("GradleDokkaSourceSetBuilderKt") package org.jetbrains.dokka.gradle -import com.android.build.gradle.api.AndroidSourceSet import groovy.lang.Closure -import org.gradle.api.Action -import org.gradle.api.Project -import org.gradle.api.Task +import org.gradle.api.* import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property @@ -16,21 +14,17 @@ import org.gradle.kotlin.dsl.listProperty import org.gradle.kotlin.dsl.setProperty import org.gradle.util.ConfigureUtil import org.jetbrains.dokka.* -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import java.io.File import java.net.URL -internal fun Task.GradleDokkaSourceSetBuilderFactory(): (name: String) -> GradleDokkaSourceSetBuilder = - { name -> GradleDokkaSourceSetBuilder(name, project) } - - -open class GradleDokkaSourceSetBuilder constructor( +open class GradleDokkaSourceSetBuilder( @Transient @get:Input val name: String, - @Transient @get:Internal internal val project: Project + @Transient @get:Internal internal val project: Project, + @Transient @get:Internal internal val sourceSetIdFactory: NamedDomainObjectFactory<DokkaSourceSetID>, ) : DokkaConfigurationBuilder<DokkaSourceSetImpl> { - @Internal - val sourceSetID: DokkaSourceSetID = DokkaSourceSetID(project, name) + @Input + val sourceSetID: DokkaSourceSetID = sourceSetIdFactory.create(name) @Input val suppress: Property<Boolean> = project.objects.safeProperty<Boolean>() @@ -42,10 +36,6 @@ open class GradleDokkaSourceSetBuilder constructor( @Input @Optional - val moduleDisplayName: Property<String?> = project.objects.safeProperty() - - @Input - @Optional val displayName: Property<String?> = project.objects.safeProperty() @InputFiles @@ -125,9 +115,7 @@ open class GradleDokkaSourceSetBuilder constructor( val platform: Property<Platform> = project.objects.safeProperty<Platform>() .safeConvention(Platform.DEFAULT) - fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = - DokkaSourceSetID(project, sourceSetName) - + fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = sourceSetIdFactory.create(sourceSetName) fun dependsOn(sourceSet: SourceSet) { dependsOn(DokkaSourceSetID(sourceSet.name)) @@ -208,15 +196,3 @@ open class GradleDokkaSourceSetBuilder constructor( override fun build(): DokkaSourceSetImpl = toDokkaSourceSetImpl() } - -fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: KotlinSourceSet) { - dependsOn(DokkaSourceSetID(sourceSet.name)) -} - -fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: AndroidSourceSet) { - dependsOn(DokkaSourceSetID(sourceSet.name)) -} - -fun GradleDokkaSourceSetBuilder.kotlinSourceSet(kotlinSourceSet: KotlinSourceSet) { - configureWithKotlinSourceSet(kotlinSourceSet) -} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt new file mode 100644 index 00000000..c5c7428f --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt @@ -0,0 +1,17 @@ +package org.jetbrains.dokka.gradle + +import com.android.build.gradle.api.AndroidSourceSet +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet + +fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: KotlinSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: AndroidSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSetBuilder.kotlinSourceSet(kotlinSourceSet: KotlinSourceSet) { + configureWithKotlinSourceSet(kotlinSourceSet) +} + diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt new file mode 100644 index 00000000..49c489c7 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt @@ -0,0 +1,9 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.NamedDomainObjectFactory +import org.gradle.api.Task + +@Suppress("ObjectLiteralToLambda") // Will fail at runtime in Gradle versions <= 6.6 +fun AbstractDokkaTask.gradleDokkaSourceSetBuilderFactory(): NamedDomainObjectFactory<GradleDokkaSourceSetBuilder> = + NamedDomainObjectFactory { name -> GradleDokkaSourceSetBuilder(name, project, DokkaSourceSetIdFactory()) } + diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt index 3fadb4fd..41cc19e3 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt @@ -2,9 +2,14 @@ package org.jetbrains.dokka.gradle -import org.gradle.api.Project +import org.gradle.api.NamedDomainObjectFactory +import org.gradle.api.Task import org.jetbrains.dokka.DokkaSourceSetID -internal fun DokkaSourceSetID(project: Project, sourceSetName: String): DokkaSourceSetID { - return DokkaSourceSetID(moduleName = project.path, sourceSetName = sourceSetName) +internal fun DokkaSourceSetID(task: Task, sourceSetName: String): DokkaSourceSetID { + return DokkaSourceSetID(task.path, sourceSetName) +} + +internal fun Task.DokkaSourceSetIdFactory() = NamedDomainObjectFactory<DokkaSourceSetID> { name -> + DokkaSourceSetID(this@DokkaSourceSetIdFactory, name) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt index 0f9d4053..2813d04e 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt @@ -6,7 +6,6 @@ import java.io.File internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetImpl = DokkaSourceSetImpl( classpath = classpath.toList(), - moduleDisplayName = moduleNameOrDefault(), displayName = displayNameOrDefault(), sourceSetID = sourceSetID, sourceRoots = sourceRoots.toSet(), @@ -29,11 +28,6 @@ internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetI analysisPlatform = platform.getSafe() ) - -private fun GradleDokkaSourceSetBuilder.moduleNameOrDefault(): String { - return moduleDisplayName.getSafe() ?: project.name -} - private fun GradleDokkaSourceSetBuilder.displayNameOrDefault(): String { displayName.getSafe()?.let { return it } if (name.endsWith("Main") && name != "Main") { diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt index efe03c56..c06a3992 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt @@ -1,9 +1,7 @@ package org.jetbrains.dokka.gradle import org.gradle.api.artifacts.FileCollectionDependency -import org.gradle.api.file.ConfigurableFileCollection import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.property import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.dokka.Platform import org.jetbrains.dokka.gradle.kotlin.KotlinSourceSetGist diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt index 04dd1eed..6e9bef38 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt @@ -33,6 +33,7 @@ class DokkaCollectorTaskTest { val collectorTasks = rootProject.tasks.withType<DokkaCollectorTask>() collectorTasks.configureEach { task -> + task.moduleName by "custom Module Name" task.outputDirectory by File("customOutputDirectory") task.cacheRoot by File("customCacheRoot") task.failOnWarning by true @@ -45,6 +46,7 @@ class DokkaCollectorTaskTest { val dokkaConfiguration = task.buildDokkaConfiguration() assertEquals( DokkaConfigurationImpl( + moduleName = "custom Module Name", outputDir = File("customOutputDirectory"), cacheRoot = File("customCacheRoot"), failOnWarning = true, diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt index 29532877..d1bfb0e1 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt @@ -28,7 +28,6 @@ class DokkaConfigurationJsonTest { this.pluginsConfiguration.put("0", "a") this.pluginsConfiguration.put("1", "b") this.dokkaSourceSets.create("main") { sourceSet -> - sourceSet.moduleDisplayName by "moduleDisplayName" sourceSet.displayName by "customSourceSetDisplayName" sourceSet.reportUndocumented by true diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt index f22a5b8c..99fca12d 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt @@ -35,7 +35,6 @@ class DokkaConfigurationSerializableTest { this.pluginsConfiguration.put("0", "a") this.pluginsConfiguration.put("1", "b") this.dokkaSourceSets.create("main") { sourceSet -> - sourceSet.moduleDisplayName by "moduleDisplayName" sourceSet.displayName by "customSourceSetDisplayName" sourceSet.reportUndocumented by true diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt index 62c867ba..5b9413c8 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt @@ -58,6 +58,7 @@ class DokkaMultiModuleTaskTest { assertTrue(multimoduleTasks.isNotEmpty(), "Expected at least one multimodule task") multimoduleTasks.configureEach { task -> + task.moduleName by "custom Module Name" task.documentationFileName by "customDocumentationFileName.md" task.outputDirectory by task.project.buildDir.resolve("customOutputDirectory") task.cacheRoot by File("customCacheRoot") @@ -70,6 +71,7 @@ class DokkaMultiModuleTaskTest { val dokkaConfiguration = task.buildDokkaConfiguration() assertEquals( DokkaConfigurationImpl( + moduleName = "custom Module Name", outputDir = task.project.buildDir.resolve("customOutputDirectory"), cacheRoot = File("customCacheRoot"), pluginsConfiguration = mapOf("pluginA" to "configA"), diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt new file mode 100644 index 00000000..c555985b --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt @@ -0,0 +1,11 @@ +@file:Suppress("TestFunctionName") + +package org.jetbrains.dokka.gradle + +import org.gradle.api.Project +import org.jetbrains.dokka.DokkaSourceSetID + +fun GradleDokkaSourceSetBuilder(name: String, project: Project, sourceSetScopeId: String = "${project.path}:test"): + GradleDokkaSourceSetBuilder { + return GradleDokkaSourceSetBuilder(name, project) { DokkaSourceSetID(sourceSetScopeId, it) } +} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt index c1053069..920c48b4 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt @@ -1,6 +1,9 @@ +@file:Suppress("TestFunctionName") + package org.jetbrains.dokka.gradle import com.android.build.gradle.internal.api.DefaultAndroidSourceSet +import org.gradle.api.Project import org.gradle.kotlin.dsl.closureOf import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.dokka.* @@ -15,14 +18,14 @@ class GradleDokkaSourceSetBuilderTest { @Test fun sourceSetId() { - val sourceSet = GradleDokkaSourceSetBuilder("myName", project) + val sourceSet = GradleDokkaSourceSetBuilder("myName", project, "scopeId") assertEquals( - DokkaSourceSetID(project, "myName"), sourceSet.sourceSetID, + DokkaSourceSetID("scopeId", "myName"), sourceSet.sourceSetID, "Expected sourceSet.sourceSetID to match output of DokkaSourceSetID factory function" ) assertEquals( - ":/myName", sourceSet.sourceSetID.toString(), + "scopeId/myName", sourceSet.sourceSetID.toString(), "Expected SourceSetId's string representation" ) } @@ -46,29 +49,6 @@ class GradleDokkaSourceSetBuilderTest { } @Test - fun moduleDisplayName() { - val sourceSet = GradleDokkaSourceSetBuilder("myName", project) - - assertNull( - sourceSet.moduleDisplayName.getSafe(), - "Expected no ${GradleDokkaSourceSetBuilder::moduleDisplayName.name} being set by default" - ) - - assertEquals( - "root", sourceSet.build().moduleDisplayName, - "Expected project name being used for ${DokkaConfiguration.DokkaSourceSet::moduleDisplayName.name} " + - "after building source set with no ${GradleDokkaSourceSetBuilder::moduleDisplayName.name} being set" - ) - - sourceSet.moduleDisplayName by "displayName" - - assertEquals( - "displayName", sourceSet.build().moduleDisplayName, - "Expected previously set ${GradleDokkaSourceSetBuilder::displayName.name} to be present after build" - ) - } - - @Test fun displayName() { val sourceSet = GradleDokkaSourceSetBuilder("myName", project) assertNull( @@ -128,9 +108,9 @@ class GradleDokkaSourceSetBuilderTest { val sourceSet = GradleDokkaSourceSetBuilder("", project) assertEquals(emptySet(), sourceSet.build().dependentSourceSets, "Expected no dependent sourceSets by default") - sourceSet.dependentSourceSets.add(DokkaSourceSetID(project, "s1")) + sourceSet.dependentSourceSets.add(sourceSet.DokkaSourceSetID("s1")) sourceSet.dependsOn("s2") - sourceSet.dependsOn(DokkaSourceSetID(project, "s3")) + sourceSet.dependsOn(sourceSet.DokkaSourceSetID("s3")) sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s4", project)) sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s5", project).build()) sourceSet.dependsOn(DefaultKotlinSourceSet(project, "s6")) @@ -456,3 +436,6 @@ class GradleDokkaSourceSetBuilderTest { ) } } + +private fun GradleDokkaSourceSetBuilder(name: String, project: Project) = + GradleDokkaSourceSetBuilder(name, project, project.path) diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt index 6a356b79..9c788a01 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt @@ -50,7 +50,7 @@ class KotlinDslDokkaTaskConfigurationTest { ) assertEquals( - DokkaSourceSetID(project.path, "commonMain"), commonMain.sourceSetID + DokkaSourceSetID(dokkaTask, "commonMain"), commonMain.sourceSetID ) } } @@ -83,14 +83,14 @@ class KotlinDslDokkaTaskConfigurationTest { val kotlin = project.extensions.getByName("kotlin") as KotlinJvmProjectExtension - project.tasks.withType(DokkaTask::class.java).first().run { + project.tasks.withType(DokkaTask::class.java).first().apply { dokkaSourceSets.run { val special = create("special") { it.dependsOn(kotlin.sourceSets.getByName("main")) } assertEquals( - DokkaSourceSetID(project, "main"), special.dependentSourceSets.get().single() + DokkaSourceSetID(this@apply, "main"), special.dependentSourceSets.get().single() ) } } diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index b95b94c0..4e5e053a 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -101,9 +101,6 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependenc @Parameter(required = true, defaultValue = "\${project.artifactId}") var moduleName: String = "" - @Parameter - var moduleDisplayName: String = "" - @Parameter(required = false, defaultValue = "false") var skip: Boolean = false @@ -190,7 +187,6 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependenc } val sourceSet = DokkaSourceSetImpl( - moduleDisplayName = moduleDisplayName.takeIf(String::isNotBlank) ?: moduleName, displayName = displayName, sourceSetID = DokkaSourceSetID(moduleName, sourceSetName), classpath = classpath.map(::File), @@ -229,12 +225,11 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependenc val logger = MavenDokkaLogger(log) val configuration = DokkaConfigurationImpl( + moduleName = moduleName, outputDir = File(getOutDir()), offlineMode = offlineMode, cacheRoot = cacheRoot?.let(::File), - sourceSets = listOf(sourceSet).also { - if (sourceSet.moduleDisplayName.isEmpty()) logger.warn("Not specified module name. It can result in unexpected behaviour while including documentation for module") - }, + sourceSets = listOf(sourceSet), pluginsClasspath = getArtifactByAether("org.jetbrains.dokka", "dokka-base", dokkaVersion) + dokkaPlugins.map { getArtifactByAether(it.groupId, it.artifactId, it.version ?: dokkaVersion) } .flatten(), |