aboutsummaryrefslogtreecommitdiff
path: root/runners/cli/src
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-27 15:50:40 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-31 15:10:04 +0200
commit8cd28416817dfd7d28bb66b28e849d97cc09012b (patch)
tree962f9420f3ccdb47d6847c9e5a16d00018c9110c /runners/cli/src
parent732d181e4908ed0ddc513e305addc71560c0e109 (diff)
downloaddokka-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 'runners/cli/src')
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt39
1 files changed, 18 insertions, 21 deletions
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() = ""