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, - |
