diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-06-30 23:06:03 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-06 17:59:15 +0200 |
commit | b0e8622f374f6499058b0f083367b4a54512b702 (patch) | |
tree | 0fa641dc26bf1e7ed6497ee2340999e8ecc505ad /runners/cli/src/main | |
parent | b0b418334535adc60ee80c3df1b2293dfcaad071 (diff) | |
download | dokka-b0e8622f374f6499058b0f083367b4a54512b702.tar.gz dokka-b0e8622f374f6499058b0f083367b4a54512b702.tar.bz2 dokka-b0e8622f374f6499058b0f083367b4a54512b702.zip |
Enforce workspace unique SourceSetID
Diffstat (limited to 'runners/cli/src/main')
-rw-r--r-- | runners/cli/src/main/kotlin/cli/main.kt | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index b0fb45b2..5e5cd6b2 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -1,6 +1,5 @@ package org.jetbrains.dokka -import com.google.gson.Gson import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet.* @@ -34,7 +33,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { override val sourceSets by parser.option( ArgTypeArgument, description = "Single dokka source set", - fullName = "pass" + fullName = "sourceSet" ).multiple() override val pluginsConfiguration by parser.option( @@ -60,7 +59,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { val globalPackageOptions by parser.option( ArgType.String, - description = "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " + description = "List of package source sets in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " ).delimiter(";") val globalLinks by parser.option( @@ -73,9 +72,9 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { description = "Mapping between a source directory and a Web site for browsing the code (allows many paths separated by the semicolon `;`)" ).delimiter(";") - val helpPass by parser.option( - ArgTypeHelpPass, - description = "Prints help for single -pass" + val helpSourceSet by parser.option( + ArgTypeHelpSourceSet, + description = "Prints help for single -sourceSet" ) override val modules: List<DokkaConfiguration.DokkaModuleDescription> = emptyList() @@ -94,8 +93,8 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { globalSrcLink.forEach { if (it.isNotEmpty() && it.contains("=")) - sourceSets.all { pass -> - pass.sourceLinks.cast<MutableList<SourceLinkDefinitionImpl>>() + sourceSets.all { sourceSet -> + sourceSet.sourceLinks.cast<MutableList<SourceLinkDefinitionImpl>>() .add(SourceLinkDefinitionImpl.parseSourceLinkDefinition(it)) } else { @@ -112,9 +111,9 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { } } -fun passArguments(args: Array<String>): DokkaConfiguration.DokkaSourceSet { +private fun parseSourceSet(args: Array<String>): DokkaConfiguration.DokkaSourceSet { - val parser = ArgParser("passConfiguration", prefixStyle = ArgParser.OptionPrefixStyle.JVM) + val parser = ArgParser("sourceSet", prefixStyle = ArgParser.OptionPrefixStyle.JVM) val moduleName by parser.option( ArgType.String, @@ -122,16 +121,21 @@ fun passArguments(args: Array<String>): DokkaConfiguration.DokkaSourceSet { fullName = "module" ).required() - val displayName by parser.option( + val moduleDisplayName by parser.option( ArgType.String, - description = "Name of the source set" - ).default("JVM") + description = "Name of the documentation module" + ) - val sourceSetID by parser.option( + val name by parser.option( ArgType.String, - description = "ID of the source set" + description = "Name of the source set" ).default("main") + val displayName by parser.option( + ArgType.String, + description = "Displayed name of the source set" + ).default("JVM") + val classpath by parser.option( ArgType.String, description = "Classpath for symbol resolution (allows many paths separated by the semicolon `;`)" @@ -213,7 +217,7 @@ fun passArguments(args: Array<String>): DokkaConfiguration.DokkaSourceSet { val perPackageOptions by parser.option( ArgType.String, - description = "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " + description = "List of package source set configuration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " ).delimiter(";") val externalDocumentationLinks by parser.option( @@ -230,12 +234,14 @@ fun passArguments(args: Array<String>): DokkaConfiguration.DokkaSourceSet { parser.parse(args) return object : DokkaConfiguration.DokkaSourceSet { - override val moduleName = moduleName + override val moduleDisplayName = moduleDisplayName ?: moduleName override val displayName = displayName - override val sourceSetID = sourceSetID + override val sourceSetID = DokkaSourceSetID(moduleName, name) override val classpath = classpath override val sourceRoots = sourceRoots.map { SourceRootImpl(it.toAbsolutePath()) } - override val dependentSourceSets: List<String> = dependentSourceSets + override val dependentSourceSets: Set<DokkaSourceSetID> = dependentSourceSets + .map { dependentSourceSetName -> DokkaSourceSetID(moduleName, dependentSourceSetName) } + .toSet() override val samples = samples.map { it.toAbsolutePath() } override val includes = includes.map { it.toAbsolutePath() } override val includeNonPublic = includeNonPublic @@ -294,15 +300,15 @@ object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefini object ArgTypeArgument : ArgType<DokkaConfiguration.DokkaSourceSet>(true) { override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet = - passArguments(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) + parseSourceSet(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) override val description: kotlin.String get() = "" } // Workaround for printing nested parsers help -object ArgTypeHelpPass : ArgType<Any>(false) { - override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { passArguments(arrayOf("-h")) } +object ArgTypeHelpSourceSet : ArgType<Any>(false) { + override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { parseSourceSet(arrayOf("-h")) } override val description: kotlin.String get() = "" @@ -345,11 +351,10 @@ fun parseLinks(links: List<String>): List<ExternalDocumentationLink> { fun main(args: Array<String>) { val globalArguments = GlobalArguments(args) val configuration = if (globalArguments.json != null) - Gson().fromJson( - Paths.get(globalArguments.json).toFile().readText(), - DokkaConfigurationImpl::class.java + DokkaConfigurationImpl( + Paths.get(checkNotNull(globalArguments.json)).toFile().readText() ) else globalArguments DokkaGenerator(configuration, DokkaConsoleLogger).generate() -}
\ No newline at end of file +} |