diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-27 15:50:40 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-31 15:10:04 +0200 |
commit | 8cd28416817dfd7d28bb66b28e849d97cc09012b (patch) | |
tree | 962f9420f3ccdb47d6847c9e5a16d00018c9110c /core/test-api | |
parent | 732d181e4908ed0ddc513e305addc71560c0e109 (diff) | |
download | dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.tar.gz dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.tar.bz2 dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.zip |
Let module name be configurable withing `AbstractDokkaTask` and remove concept of `moduleDisplayName`
Diffstat (limited to 'core/test-api')
-rw-r--r-- | core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt | 39 |
1 files changed, 23 insertions, 16 deletions
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(), |