aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-28 11:28:54 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-31 15:10:04 +0200
commit02ccae10e3f717c330dae5d87b49a0e72f798905 (patch)
tree4c63d6039fdc5a20c065724e672adbc5c6a3a0e5
parent8cd28416817dfd7d28bb66b28e849d97cc09012b (diff)
downloaddokka-02ccae10e3f717c330dae5d87b49a0e72f798905.tar.gz
dokka-02ccae10e3f717c330dae5d87b49a0e72f798905.tar.bz2
dokka-02ccae10e3f717c330dae5d87b49a0e72f798905.zip
Re-use includes form child tasks for all modules page generation
-rw-r--r--core/src/main/kotlin/configuration.kt12
-rw-r--r--core/src/main/kotlin/defaultConfiguration.kt4
-rw-r--r--core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt1
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/Module.md6
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/README.md2
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/build.gradle.kts9
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/Module.md (renamed from integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/README.md)0
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/build.gradle.kts8
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/build.gradle.kts10
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/src/main/kotlin/org/jetbrains/dokka/it/moduleD/ModuleC.kt6
-rw-r--r--integration-tests/gradle/projects/it-multimodule-0/settings.gradle.kts1
-rw-r--r--plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt60
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt2
-rw-r--r--plugins/base/src/test/kotlin/model/PackagesTest.kt2
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt27
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt145
16 files changed, 178 insertions, 117 deletions
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt
index 9a1ff602..b53fd1ee 100644
--- a/core/src/main/kotlin/configuration.kt
+++ b/core/src/main/kotlin/configuration.kt
@@ -61,6 +61,14 @@ fun <T : Any> Iterable<DokkaConfigurationBuilder<T>>.build(): List<T> = this.map
data class DokkaSourceSetID(
+ /**
+ * Unique identifier of the scope that this source set is placed in.
+ * Each scope provide only unique source set names.
+ *
+ * E.g. One DokkaTask inside the Gradle plugin represents one source set scope, since there cannot be multiple
+ * source sets with the same name. However, a Gradle project will not be a proper scope, since there can be
+ * multple DokkaTasks that contain source sets with the same name (but different configuration)
+ */
val scopeId: String,
val sourceSetName: String
) : Serializable {
@@ -116,8 +124,8 @@ interface DokkaConfiguration : Serializable {
interface DokkaModuleDescription : Serializable {
val name: String
- val path: File
- val docFile: File
+ val relativePathToOutputDirectory: File
+ val includes: Set<File>
}
interface PackageOptions : Serializable {
diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt
index 3fcc7aac..5b32ebae 100644
--- a/core/src/main/kotlin/defaultConfiguration.kt
+++ b/core/src/main/kotlin/defaultConfiguration.kt
@@ -43,8 +43,8 @@ data class DokkaSourceSetImpl(
data class DokkaModuleDescriptionImpl(
override val name: String,
- override val path: File,
- override val docFile: File
+ override val relativePathToOutputDirectory: File,
+ override val includes: Set<File>
) : DokkaConfiguration.DokkaModuleDescription
data class SourceLinkDefinitionImpl(
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 f6cb99db..2d9f99b2 100644
--- a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt
+++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt
@@ -138,7 +138,6 @@ val defaultSourceSet = DokkaSourceSetImpl(
analysisPlatform = Platform.DEFAULT
)
-// TODO NOW: Clean up
fun sourceSet(name: String): DokkaConfiguration.DokkaSourceSet {
return defaultSourceSet.copy(
displayName = name,
diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/Module.md b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/Module.md
new file mode 100644
index 00000000..0570f467
--- /dev/null
+++ b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/Module.md
@@ -0,0 +1,6 @@
+# Module !Module B!
+Here is some description for Module B
+
+Module B: Second paragraph
+# Module moduleB
+§IGNORED$This documentation shall be ignored, because wrong module name§IGNORED$
diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/README.md b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/README.md
deleted file mode 100644
index f8c52880..00000000
--- a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# Module moduleB
-Here is some description for module B
diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/build.gradle.kts b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/build.gradle.kts
index 9492fdc8..5f0b69c7 100644
--- a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/build.gradle.kts
+++ b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleB/build.gradle.kts
@@ -1,3 +1,5 @@
+import org.jetbrains.dokka.gradle.DokkaTask
+
plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
@@ -6,3 +8,10 @@ plugins {
dependencies {
implementation(kotlin("stdlib"))
}
+
+tasks.withType<DokkaTask>().configureEach {
+ moduleName.set("!Module B!")
+ dokkaSourceSets.configureEach {
+ includes.from("Module.md")
+ }
+}
diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/README.md b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/Module.md
index 4ead5671..4ead5671 100644
--- a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/README.md
+++ b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/Module.md
diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/build.gradle.kts b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/build.gradle.kts
index 9492fdc8..e471d375 100644
--- a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/build.gradle.kts
+++ b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleC/build.gradle.kts
@@ -1,3 +1,5 @@
+import org.jetbrains.dokka.gradle.DokkaTask
+
plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
@@ -6,3 +8,9 @@ plugins {
dependencies {
implementation(kotlin("stdlib"))
}
+
+tasks.withType<DokkaTask>().configureEach {
+ dokkaSourceSets.configureEach {
+ includes.from("Module.md")
+ }
+}
diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/build.gradle.kts b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/build.gradle.kts
new file mode 100644
index 00000000..a16e038f
--- /dev/null
+++ b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/build.gradle.kts
@@ -0,0 +1,10 @@
+import org.jetbrains.dokka.gradle.DokkaTask
+
+plugins {
+ kotlin("jvm")
+ id("org.jetbrains.dokka")
+}
+
+dependencies {
+ implementation(kotlin("stdlib"))
+}
diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/src/main/kotlin/org/jetbrains/dokka/it/moduleD/ModuleC.kt b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/src/main/kotlin/org/jetbrains/dokka/it/moduleD/ModuleC.kt
new file mode 100644
index 00000000..88174d53
--- /dev/null
+++ b/integration-tests/gradle/projects/it-multimodule-0/moduleA/moduleD/src/main/kotlin/org/jetbrains/dokka/it/moduleD/ModuleC.kt
@@ -0,0 +1,6 @@
+package org.jetbrains.dokka.it.moduleD
+
+@Suppress("unused")
+class ModuleD {
+ fun undocumentedPublicFunction() {}
+}
diff --git a/integration-tests/gradle/projects/it-multimodule-0/settings.gradle.kts b/integration-tests/gradle/projects/it-multimodule-0/settings.gradle.kts
index a5c89291..dda6558f 100644
--- a/integration-tests/gradle/projects/it-multimodule-0/settings.gradle.kts
+++ b/integration-tests/gradle/projects/it-multimodule-0/settings.gradle.kts
@@ -3,3 +3,4 @@ rootProject.name = "it-multimodule-0"
include(":moduleA")
include(":moduleA:moduleB")
include(":moduleA:moduleC")
+include(":moduleA:moduleD")
diff --git a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
index a87d4319..dab06343 100644
--- a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
+++ b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
@@ -1,9 +1,13 @@
package org.jetbrains.dokka.base.allModulePage
-import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaConfiguration.DokkaModuleDescription
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
-import org.jetbrains.dokka.DokkaException
import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.parsers.MarkdownParser
+import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier.Module
+import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentationParsingContext
+import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDocumentation
+import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDocumentationFragments
import org.jetbrains.dokka.base.resolvers.local.MultimoduleLocationProvider.Companion.MULTIMODULE_PACKAGE_PLACEHOLDER
import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
@@ -11,21 +15,19 @@ import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.doc.DocumentationNode
import org.jetbrains.dokka.model.doc.P
import org.jetbrains.dokka.pages.*
-import org.jetbrains.dokka.base.parsers.MarkdownParser
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
-class MultimodulePageCreator(
- val context: DokkaContext
+class MultimodulePageCreator (
+ private val context: DokkaContext,
) : PageCreator {
private val logger: DokkaLogger = context.logger
override fun invoke(): RootPageNode {
val parser = MarkdownParser(logger = logger)
val modules = context.configuration.modules
- modules.forEach(::throwOnMissingModuleDocFile)
val commentsConverter = context.plugin(DokkaBase::class)?.querySingle { commentsToContentConverter }
val signatureProvider = context.plugin(DokkaBase::class)?.querySingle { signatureProvider }
@@ -41,20 +43,22 @@ class MultimodulePageCreator(
) {
header(2, "All modules:")
table(styles = setOf(MultimoduleTable)) {
- modules.mapNotNull { module ->
- val paragraph = module.docFile.readText().let { parser.parse(it).firstParagraph() }
- paragraph?.let {
- val dri = DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = module.name)
- val dci = DCI(setOf(dri), ContentKind.Comment)
- val header = linkNode(module.name, dri)
- val content = ContentGroup(
- DocTagToContentConverter.buildContent(it, dci, emptySet()),
- dci,
- emptySet(),
- emptySet()
- )
- ContentGroup(listOf(header, content), dci, emptySet(), emptySet())
- }
+ modules.map { module ->
+ val displayedModuleDocumentation = getDisplayedModuleDocumentation(module)
+ val dri = DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = module.name)
+ val dci = DCI(setOf(dri), ContentKind.Comment)
+ val header =
+ ContentHeader(listOf(linkNode(module.name, dri)), 2, dci, emptySet(), emptySet())
+ val content = ContentGroup(
+ children =
+ if (displayedModuleDocumentation != null)
+ DocTagToContentConverter.buildContent(displayedModuleDocumentation, dci, emptySet())
+ else emptyList(),
+ dci = dci,
+ sourceSets = emptySet(),
+ style = emptySet()
+ )
+ ContentGroup(listOf(header, content), dci, emptySet(), emptySet())
}
}
}
@@ -65,12 +69,16 @@ class MultimodulePageCreator(
)
}
- private fun throwOnMissingModuleDocFile(module: DokkaConfiguration.DokkaModuleDescription) {
- if (!module.docFile.exists() || !module.docFile.isFile) {
- throw DokkaException(
- "Missing documentation file for module ${module.name}: ${module.docFile.absolutePath}"
- )
- }
+ private fun getDisplayedModuleDocumentation(module: DokkaModuleDescription): P? {
+ val parsingContext = ModuleAndPackageDocumentationParsingContext(logger)
+ return module.includes
+ .flatMap { include -> parseModuleAndPackageDocumentationFragments(include) }
+ .map { fragment -> parseModuleAndPackageDocumentation(parsingContext, fragment) }
+ .firstOrNull { documentation -> documentation.classifier == Module && documentation.name == module.name }
+ ?.documentation?.children.orEmpty()
+ .flatMap { it.root.children }
+ .filterIsInstance<P>()
+ .firstOrNull()
}
private fun DocumentationNode.firstParagraph() =
diff --git a/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt
index 3e0122bf..b5891dbf 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt
@@ -12,7 +12,7 @@ class MultimoduleLocationProvider(private val root: RootPageNode, context: Dokka
private val defaultLocationProvider = DokkaLocationProvider(root, context)
val paths = context.configuration.modules.map {
- it.name to it.path
+ it.name to it.relativePathToOutputDirectory
}.toMap()
override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) =
diff --git a/plugins/base/src/test/kotlin/model/PackagesTest.kt b/plugins/base/src/test/kotlin/model/PackagesTest.kt
index 1adf7626..3deb95e9 100644
--- a/plugins/base/src/test/kotlin/model/PackagesTest.kt
+++ b/plugins/base/src/test/kotlin/model/PackagesTest.kt
@@ -117,8 +117,6 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac
}
}
- // TODO NOW test displayName
-
// todo
// @Test fun suppressAtPackageLevel() {
// verifyModel(
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 82e2148f..92560c94 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,8 +3,6 @@ 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
@@ -14,26 +12,15 @@ import java.io.File
@Deprecated("Use 'DokkaMultimoduleTask' instead", ReplaceWith("DokkaMultimoduleTask"))
typealias DokkaMultimoduleTask = DokkaMultiModuleTask
+private typealias TaskPath = String
abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBootstrapImpl::class) {
- /**
- * Name of the file containing all necessary module information.
- * This file has to be placed inside the subproject root directory.
- */
- @Internal
- val documentationFileName: Property<String> = project.objects.safeProperty<String>()
- .safeConvention("README.md")
-
@Internal
val fileLayout: Property<DokkaMultiModuleFileLayout> = project.objects.safeProperty<DokkaMultiModuleFileLayout>()
.safeConvention(DokkaMultiModuleFileLayout.CompactInParent)
@get:InputFiles
- internal val childDocumentationFiles: Iterable<File>
- get() = childDokkaTasks.map { task -> task.project.projectDir.resolve(documentationFileName.getSafe()) }
-
- @get:InputFiles
internal val sourceChildOutputDirectories: Iterable<File>
get() = childDokkaTasks.map { task -> task.outputDirectory.getSafe() }
@@ -41,6 +28,12 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo
internal val targetChildOutputDirectories: Iterable<File>
get() = childDokkaTasks.map { task -> targetChildOutputDirectory(task) }
+ @get:Input
+ internal val childDokkaTaskIncludes: Map<TaskPath, Set<File>>
+ get() = childDokkaTasks.filterIsInstance<DokkaTask>().associate { task ->
+ task.path to task.dokkaSourceSets.flatMap { it.includes }.toSet()
+ }
+
@Internal
override fun getTaskDependencies(): TaskDependencyInternal =
super.getTaskDependencies() + childDokkaTasks
@@ -62,9 +55,9 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo
pluginsClasspath = plugins.resolve().toList(),
modules = childDokkaTasks.map { dokkaTask ->
DokkaModuleDescriptionImpl(
- name = dokkaTask.project.name,
- path = targetChildOutputDirectory(dokkaTask).relativeTo(outputDirectory.getSafe()),
- docFile = dokkaTask.project.projectDir.resolve(documentationFileName.get()).absoluteFile
+ name = dokkaTask.moduleName.getSafe(),
+ relativePathToOutputDirectory = targetChildOutputDirectory(dokkaTask).relativeTo(outputDirectory.getSafe()),
+ includes = childDokkaTaskIncludes[dokkaTask.path].orEmpty()
)
}
)
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 5b9413c8..bea80f1e 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
@@ -2,8 +2,7 @@
package org.jetbrains.dokka.gradle
-import org.gradle.kotlin.dsl.create
-import org.gradle.kotlin.dsl.withType
+import org.gradle.kotlin.dsl.*
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.DokkaConfigurationImpl
import org.jetbrains.dokka.DokkaException
@@ -25,10 +24,14 @@ class DokkaMultiModuleTaskTest {
.withProjectDir(rootProject.projectDir.resolve("child"))
.withParent(rootProject).build()
+ private val childDokkaTask = childProject.tasks.create<DokkaTask>("childDokkaTask")
+
+ private val multiModuleTask = rootProject.tasks.create<DokkaMultiModuleTask>("multiModuleTask").apply {
+ addChildTask(childDokkaTask)
+ }
+
init {
rootProject.allprojects { project ->
- project.plugins.apply("org.jetbrains.kotlin.jvm")
- project.plugins.apply("org.jetbrains.dokka")
project.tasks.withType<AbstractDokkaTask>().configureEach { task ->
task.plugins.withDependencies { dependencies -> dependencies.clear() }
}
@@ -50,70 +53,66 @@ class DokkaMultiModuleTaskTest {
@Test
fun buildDokkaConfiguration() {
- childProject.tasks.withType<DokkaTask>().configureEach { task ->
- task.outputDirectory by task.project.buildDir.resolve("output")
+ val include1 = childDokkaTask.project.file("include1.md")
+ val include2 = childDokkaTask.project.file("include2.md")
+
+ childDokkaTask.apply {
+ dokkaSourceSets.create("main")
+ dokkaSourceSets.create("test")
+ dokkaSourceSets.configureEach {
+ it.includes.from(include1, include2)
+ }
}
- val multimoduleTasks = rootProject.tasks.withType<DokkaMultiModuleTask>()
- 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")
- task.pluginsConfiguration.put("pluginA", "configA")
- task.failOnWarning by true
- task.offlineMode by true
+ multiModuleTask.apply {
+ moduleName by "custom Module Name"
+ outputDirectory by project.buildDir.resolve("customOutputDirectory")
+ cacheRoot by File("customCacheRoot")
+ pluginsConfiguration.put("pluginA", "configA")
+ failOnWarning by true
+ offlineMode by true
}
- multimoduleTasks.forEach { task ->
- val dokkaConfiguration = task.buildDokkaConfiguration()
- assertEquals(
- DokkaConfigurationImpl(
- moduleName = "custom Module Name",
- outputDir = task.project.buildDir.resolve("customOutputDirectory"),
- cacheRoot = File("customCacheRoot"),
- pluginsConfiguration = mapOf("pluginA" to "configA"),
- pluginsClasspath = emptyList(),
- failOnWarning = true,
- offlineMode = true,
- modules = listOf(
- DokkaModuleDescriptionImpl(
- name = "child",
- path = File("child"),
- docFile = childProject.projectDir.resolve("customDocumentationFileName.md")
- )
+ val dokkaConfiguration = multiModuleTask.buildDokkaConfiguration()
+ assertEquals(
+ DokkaConfigurationImpl(
+ moduleName = "custom Module Name",
+ outputDir = multiModuleTask.project.buildDir.resolve("customOutputDirectory"),
+ cacheRoot = File("customCacheRoot"),
+ pluginsConfiguration = mapOf("pluginA" to "configA"),
+ pluginsClasspath = emptyList(),
+ failOnWarning = true,
+ offlineMode = true,
+ modules = listOf(
+ DokkaModuleDescriptionImpl(
+ name = "child",
+ relativePathToOutputDirectory = File("child"),
+ includes = setOf(include1, include2)
)
- ),
- dokkaConfiguration
- )
- }
+ )
+ ),
+ dokkaConfiguration
+ )
}
@Test
fun `setting dokkaTaskNames declares proper task dependencies`() {
- val multimoduleTasks = rootProject.tasks.withType<DokkaMultiModuleTask>()
- assertTrue(multimoduleTasks.isNotEmpty(), "Expected at least one multimodule task")
+ val dependenciesInitial = multiModuleTask.taskDependencies.getDependencies(multiModuleTask).toSet()
+ assertEquals(1, dependenciesInitial.size, "Expected one dependency")
+ val dependency = dependenciesInitial.single()
- multimoduleTasks.toList().forEach { task ->
- val dependencies = task.taskDependencies.getDependencies(task).toSet()
- assertEquals(1, dependencies.size, "Expected one dependency")
- val dependency = dependencies.single()
+ assertTrue(dependency is DokkaTask, "Expected dependency to be of Type ${DokkaTask::class.simpleName}")
+ assertEquals(childProject, dependency.project, "Expected dependency from child project")
- assertTrue(dependency is DokkaTask, "Expected dependency to be of Type ${DokkaTask::class.simpleName}")
- assertEquals(childProject, dependency.project, "Expected dependency from child project")
- }
val customDokkaTask = childProject.tasks.create<DokkaTask>("customDokkaTask")
- multimoduleTasks.toList().forEach { task ->
- task.addSubprojectChildTasks("customDokkaTask")
- val dependencies = task.taskDependencies.getDependencies(task).toSet()
+ multiModuleTask.addSubprojectChildTasks("customDokkaTask")
+ val dependenciesAfter = multiModuleTask.taskDependencies.getDependencies(multiModuleTask).toSet()
+
+ assertEquals(2, dependenciesAfter.size, "Expected two dependencies")
+ assertTrue(customDokkaTask in dependenciesAfter, "Expected 'customDokkaTask' in dependencies")
- assertEquals(2, dependencies.size, "Expected two dependencies")
- assertTrue(customDokkaTask in dependencies, "Expected 'customDokkaTask' in dependencies")
- }
}
@Test
@@ -125,19 +124,38 @@ class DokkaMultiModuleTaskTest {
}
@Test
- fun childDocumentationFiles() {
- val parent = ProjectBuilder.builder().build()
- val child = ProjectBuilder.builder().withName("child").withParent(parent).build()
-
- val parentTask = parent.tasks.create<DokkaMultiModuleTask>("parent")
- val childTask = child.tasks.create<DokkaTask>("child")
+ fun childDokkaTaskIncludes() {
+ val childDokkaTaskInclude1 = childProject.file("include1")
+ val childDokkaTaskInclude2 = childProject.file("include2")
+ val childDokkaTaskInclude3 = childProject.file("include3")
+
+ childDokkaTask.apply {
+ dokkaSourceSets.create("main") {
+ it.includes.from(childDokkaTaskInclude1, childDokkaTaskInclude2)
+ }
+ dokkaSourceSets.create("main2") {
+ it.includes.from(childDokkaTaskInclude3)
+ }
+ }
- parentTask.addChildTask(childTask)
- parentTask.documentationFileName by "module.txt"
+ val secondChildDokkaTaskInclude = childProject.file("include4")
+ val secondChildDokkaTask = childProject.tasks.create<DokkaTask>("secondChildDokkaTask") {
+ dokkaSourceSets.create("main") {
+ it.includes.from(secondChildDokkaTaskInclude)
+ }
+ }
+ multiModuleTask.addChildTask(secondChildDokkaTask)
assertEquals(
- listOf(parent.file("child/module.txt")), parentTask.childDocumentationFiles,
- "Expected child documentation file being present"
+ mapOf(
+ ":child:childDokkaTask" to setOf(
+ childDokkaTaskInclude1,
+ childDokkaTaskInclude2,
+ childDokkaTaskInclude3
+ ),
+ ":child:secondChildDokkaTask" to setOf(secondChildDokkaTaskInclude)
+ ),
+ multiModuleTask.childDokkaTaskIncludes
)
}
@@ -177,6 +195,5 @@ class DokkaMultiModuleTaskTest {
listOf(parent.project.buildDir.resolve("child")), parentTask.targetChildOutputDirectories,
"Expected child target output directory being present"
)
-
}
}