From 052a218dcf8bc565d5e78dc900a9647f0da5350a Mon Sep 17 00:00:00 2001 From: aleksZubakov Date: Wed, 1 Aug 2018 19:48:45 +0300 Subject: Refactoring, replace DocumentationOption with PassConfiguration --- runners/cli/src/main/kotlin/cli/main.kt | 36 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'runners/cli/src') diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index f871f406..330de5e1 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -44,7 +44,7 @@ class DokkaArguments { @set:Argument(value = "impliedPlatforms", description = "List of implied platforms (comma-separated)") var impliedPlatforms: String = "" - @set:Argument(value = "packageOptions", description = "List of package options in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" ") + @set:Argument(value = "packageOptions", description = "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" ") var packageOptions: String = "" @set:Argument(value = "links", description = "External documentation links in format url^packageListUrl^^url2...") @@ -111,31 +111,37 @@ object MainKt { val classPath = arguments.classpath.split(File.pathSeparatorChar).toList() - val documentationOptions = DocumentationOptions( - arguments.outputDir.let { if (it.endsWith('/')) it else it + '/' }, - arguments.outputFormat, + val passConfig = PassConfigurationImpl( skipDeprecated = arguments.nodeprecated, sourceLinks = sourceLinks, - impliedPlatforms = arguments.impliedPlatforms.split(','), perPackageOptions = parsePerPackageOptions(arguments.packageOptions), jdkVersion = arguments.jdkVersion, externalDocumentationLinks = parseLinks(arguments.links), noStdlibLink = arguments.noStdlibLink, - cacheRoot = arguments.cacheRoot, languageVersion = arguments.languageVersion, apiVersion = arguments.apiVersion, collectInheritedExtensionsFromLibraries = arguments.collectInheritedExtensionsFromLibraries, - noJdkLink = arguments.noJdkLink + noJdkLink = arguments.noJdkLink, + sourceRoots = sources.map(SourceRootImpl.Companion::parseSourceRoot), + analysisPlatform = sources.map (SourceRootImpl.Companion::parseSourceRoot).single().analysisPlatform, + samples = samples, + includes = includes, + moduleName = arguments.moduleName, + classpath = classPath + ) + + val config = DokkaConfigurationImpl( + outputDir = arguments.outputDir.let { if (it.endsWith('/')) it else it + '/' }, + format = arguments.outputFormat, + impliedPlatforms = arguments.impliedPlatforms.split(','), + cacheRoot = arguments.cacheRoot, + + passesConfigurations = listOf( + passConfig + ) ) - val generator = DokkaGenerator( - DokkaConsoleLogger, - classPath, - sources.map(SourceRootImpl.Companion::parseSourceRoot), - samples, - includes, - arguments.moduleName, - documentationOptions) + val generator = DokkaGenerator(config, DokkaConsoleLogger) generator.generate() DokkaConsoleLogger.report() -- cgit From bd81f90b3502b8dd5a7a8439a323fe34a7dbd117 Mon Sep 17 00:00:00 2001 From: aleksZubakov Date: Mon, 6 Aug 2018 19:26:37 +0300 Subject: Change cli parser --- runners/cli/src/main/kotlin/cli/main.kt | 331 ++++++++++++++++++++++---------- 1 file changed, 230 insertions(+), 101 deletions(-) (limited to 'runners/cli/src') diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 330de5e1..ae2f1136 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -1,8 +1,6 @@ package org.jetbrains.dokka - -import com.sampullara.cli.Args -import com.sampullara.cli.Argument +import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import java.io.File @@ -10,66 +8,243 @@ import java.net.MalformedURLException import java.net.URL import java.net.URLClassLoader -class DokkaArguments { - @set:Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)") - var src: String = "" +data class Arguments( + override var moduleName: String = "", + override var classpath: MutableList = mutableListOf(), + override var sourceRoots: MutableList = mutableListOf(), + override var samples: MutableList = mutableListOf(), + override var includes: MutableList = mutableListOf(), + override var includeNonPublic: Boolean = false, + override var includeRootPackage: Boolean = false, + override var reportUndocumented: Boolean = false, + override var skipEmptyPackages: Boolean = false, + override var skipDeprecated: Boolean = false, + override var jdkVersion: Int = 6, + override var sourceLinks: List = listOf(), + override var perPackageOptions: List = listOf(), + override var externalDocumentationLinks: List = listOf(), + override var languageVersion: String? = "", + override var apiVersion: String? = "", + override var noStdlibLink: Boolean = false, + override var noJdkLink: Boolean = false, + override var suppressedFiles: MutableList = mutableListOf(), + override var collectInheritedExtensionsFromLibraries: Boolean = false, + override var analysisPlatform: Platform = Platform.DEFAULT, + override var targets: MutableList = mutableListOf(), + var rawPerPackageOptions: MutableList = mutableListOf() +) : DokkaConfiguration.PassConfiguration + + +data class GlobalArguments( + override var outputDir: String = "", + override var format: String = "", + override var generateIndexPages: Boolean = false, + override var cacheRoot: String? = null, + override var passesConfigurations: List = listOf(), + override var impliedPlatforms: MutableList = mutableListOf() +) : DokkaConfiguration + +class DokkaArgumentsParser { + private fun CommandLineInterface.registerSingleAction( + keys: List, + help: String, + invoke: (String) -> Unit + ) = registerAction( + object : FlagActionBase(keys, help) { + override fun invoke(arguments: ListIterator) { + if (arguments.hasNext()) { + val msg = arguments.next() + invoke(msg) + } + } - @set:Argument(value = "srcLink", description = "Mapping between a source directory and a Web site for browsing the code") - var srcLink: String = "" + override fun invoke() { + error("should be never called") + } + } - @set:Argument(value = "include", description = "Markdown files to load (allows many paths separated by the system path separator)") - var include: String = "" + ) + + private fun CommandLineInterface.registerRepeatingAction( + keys: List, + help: String, + invoke: (String) -> Unit + ) = registerAction( + object : FlagActionBase(keys, help) { + override fun invoke(arguments: ListIterator) { + while (arguments.hasNext()) { + val message = arguments.next() + + if (cli.getFlagAction(message) != null) { + arguments.previous() + break + } + invoke(message) + } - @set:Argument(value = "samples", description = "Source root for samples") - var samples: String = "" + } - @set:Argument(value = "output", description = "Output directory path") - var outputDir: String = "out/doc/" + override fun invoke() { + error("should be never called") + } + } - @set:Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)") - var outputFormat: String = "html" + ) - @set:Argument(value = "module", description = "Name of the documentation module") - var moduleName: String = "" + val cli = CommandLineInterface("dokka") + val passArguments = mutableListOf() + val globalArguments = GlobalArguments() - @set:Argument(value = "classpath", description = "Classpath for symbol resolution") - var classpath: String = "" + init { + cli.flagAction( + listOf("-pass"), + "Single dokka pass" + ) { + passArguments += Arguments() + } - @set:Argument(value = "nodeprecated", description = "Exclude deprecated members from documentation") - var nodeprecated: Boolean = false + cli.registerRepeatingAction( + listOf("-src"), + "Source file or directory (allows many paths separated by the system path separator)" + ) { + passArguments.last().sourceRoots.add(SourceRootImpl.parseSourceRoot(it)) + } - @set:Argument(value = "jdkVersion", description = "Version of JDK to use for linking to JDK JavaDoc") - var jdkVersion: Int = 6 + cli.registerRepeatingAction( + listOf("-srcLink"), + "Mapping between a source directory and a Web site for browsing the code" + ) { + println(it) + } - @set:Argument(value = "impliedPlatforms", description = "List of implied platforms (comma-separated)") - var impliedPlatforms: String = "" + cli.registerRepeatingAction( + listOf("-include"), + "Markdown files to load (allows many paths separated by the system path separator)" + ) { + passArguments.last().includes.add(it) + } - @set:Argument(value = "packageOptions", description = "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" ") - var packageOptions: String = "" + cli.registerRepeatingAction( + listOf("-samples"), + "Source root for samples" + ) { + passArguments.last().samples.add(it) + } - @set:Argument(value = "links", description = "External documentation links in format url^packageListUrl^^url2...") - var links: String = "" + cli.registerSingleAction( + listOf("-output"), + "Output directory path" + ) { + globalArguments.outputDir = it + } - @set:Argument(value = "noStdlibLink", description = "Disable documentation link to stdlib") - var noStdlibLink: Boolean = false + cli.registerSingleAction( + listOf("-format"), + "Output format (text, html, markdown, jekyll, kotlin-website)" + ) { + globalArguments.format = it + } - @set:Argument(value = "noJdkLink", description = "Disable documentation link to jdk") - var noJdkLink: Boolean = false + cli.registerSingleAction( + listOf("-module"), + "Name of the documentation module" + ) { + passArguments.last().moduleName = it + } - @set:Argument(value = "cacheRoot", description = "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled") - var cacheRoot: String? = null + cli.registerRepeatingAction( + listOf("-classpath"), + "Classpath for symbol resolution" + ) { + passArguments.last().classpath.add(it) + } - @set:Argument(value = "languageVersion", description = "Language Version to pass to Kotlin Analysis") - var languageVersion: String? = null + cli.flagAction( + listOf("-nodeprecacted"), + "Exclude deprecated members from documentation" + ) { + passArguments.last().skipDeprecated = true + } - @set:Argument(value = "apiVersion", description = "Kotlin Api Version to pass to Kotlin Analysis") - var apiVersion: String? = null + cli.registerSingleAction( + listOf("jdkVersion"), + "Version of JDK to use for linking to JDK JavaDoc" + ) { + passArguments.last().jdkVersion = Integer.parseInt(it) + } - @set:Argument(value = "collectInheritedExtensionsFromLibraries", description = "Search for applicable extensions in libraries") - var collectInheritedExtensionsFromLibraries: Boolean = false + cli.registerRepeatingAction( + listOf("-impliedPlatforms"), + "List of implied platforms (comma-separated)" + ) { + globalArguments.impliedPlatforms.add(it) + } -} + cli.registerSingleAction( + listOf("-pckageOptions"), + "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " + ) { + passArguments.last().perPackageOptions = parsePerPackageOptions(it) + } + cli.registerSingleAction( + listOf("links"), + "External documentation links in format url^packageListUrl^^url2..." + ) { + passArguments.last().externalDocumentationLinks = MainKt.parseLinks(it) + } + + cli.flagAction( + listOf("-noStdlibLink"), + "Disable documentation link to stdlib" + ) { + passArguments.last().noStdlibLink = true + } + + cli.flagAction( + listOf("-noJdkLink"), + "Disable documentation link to jdk" + ) { + passArguments.last().noJdkLink = true + } + + cli.registerSingleAction( + listOf("-cacheRoot"), + "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled" + ) { + globalArguments.cacheRoot = it + } + + cli.registerSingleAction( + listOf("-languageVersion"), + "Language Version to pass to Kotlin Analysis" + ) { + passArguments.last().languageVersion = it + } + + cli.registerSingleAction( + listOf("-apiVesion"), + "Kotlin Api Version to pass to Kotlin Analysis" + ) { + passArguments.last().apiVersion = it + } + + cli.flagAction( + listOf("-collectInheritedExtensionsFromLibraries"), + "Search for applicable extensions in libraries" + ) { + passArguments.last().collectInheritedExtensionsFromLibraries = true + } + + } + + fun parse(args: Array): DokkaConfiguration { + cli.parseArgs(*args) + + globalArguments.passesConfigurations = passArguments + return globalArguments + } +} object MainKt { @@ -93,56 +268,8 @@ object MainKt { } @JvmStatic - fun entry(args: Array) { - val arguments = DokkaArguments() - val freeArgs: List = Args.parse(arguments, args) ?: listOf() - val sources = if (arguments.src.isNotEmpty()) arguments.src.split(File.pathSeparatorChar).toList() + freeArgs else freeArgs - val samples = if (arguments.samples.isNotEmpty()) arguments.samples.split(File.pathSeparatorChar).toList() else listOf() - val includes = if (arguments.include.isNotEmpty()) arguments.include.split(File.pathSeparatorChar).toList() else listOf() - - val sourceLinks = if (arguments.srcLink.isNotEmpty() && arguments.srcLink.contains("=")) - listOf(SourceLinkDefinitionImpl.parseSourceLinkDefinition(arguments.srcLink)) - else { - if (arguments.srcLink.isNotEmpty()) { - println("Warning: Invalid -srcLink syntax. Expected: =[#lineSuffix]. No source links will be generated.") - } - listOf() - } - - val classPath = arguments.classpath.split(File.pathSeparatorChar).toList() - - val passConfig = PassConfigurationImpl( - skipDeprecated = arguments.nodeprecated, - sourceLinks = sourceLinks, - perPackageOptions = parsePerPackageOptions(arguments.packageOptions), - jdkVersion = arguments.jdkVersion, - externalDocumentationLinks = parseLinks(arguments.links), - noStdlibLink = arguments.noStdlibLink, - languageVersion = arguments.languageVersion, - apiVersion = arguments.apiVersion, - collectInheritedExtensionsFromLibraries = arguments.collectInheritedExtensionsFromLibraries, - noJdkLink = arguments.noJdkLink, - sourceRoots = sources.map(SourceRootImpl.Companion::parseSourceRoot), - analysisPlatform = sources.map (SourceRootImpl.Companion::parseSourceRoot).single().analysisPlatform, - samples = samples, - includes = includes, - moduleName = arguments.moduleName, - classpath = classPath - ) - - val config = DokkaConfigurationImpl( - outputDir = arguments.outputDir.let { if (it.endsWith('/')) it else it + '/' }, - format = arguments.outputFormat, - impliedPlatforms = arguments.impliedPlatforms.split(','), - cacheRoot = arguments.cacheRoot, - - passesConfigurations = listOf( - passConfig - ) - ) - - val generator = DokkaGenerator(config, DokkaConsoleLogger) - + fun entry(configuration: DokkaConfiguration) { + val generator = DokkaGenerator(configuration, DokkaConsoleLogger) generator.generate() DokkaConsoleLogger.report() } @@ -168,27 +295,29 @@ object MainKt { return URLClassLoader(urls, ClassLoader.getSystemClassLoader().parent) } - fun startWithToolsJar(args: Array) { + fun startWithToolsJar(configuration: DokkaConfiguration) { try { javaClass.classLoader.loadClass("com.sun.tools.doclets.formats.html.HtmlDoclet") - entry(args) + entry(configuration) } catch (e: ClassNotFoundException) { val classLoader = createClassLoaderWithTools() classLoader.loadClass("org.jetbrains.dokka.MainKt") .methods.find { it.name == "entry" }!! - .invoke(null, args) + .invoke(null, configuration) } } @JvmStatic fun main(args: Array) { - val arguments = DokkaArguments() - Args.parse(arguments, args) - if (arguments.outputFormat == "javadoc") - startWithToolsJar(args) + + val dokkaArgumentsParser = DokkaArgumentsParser() + val configuration = dokkaArgumentsParser.parse(args) + + if (configuration.format == "javadoc") + startWithToolsJar(configuration) else - entry(args) + entry(configuration) } } -- cgit From e00bfb699deb2a7781d9a15b225c68f098089107 Mon Sep 17 00:00:00 2001 From: aleksZubakov Date: Wed, 8 Aug 2018 15:47:19 +0300 Subject: Move extension function into companion object, passArguments inline --- runners/cli/src/main/kotlin/cli/main.kt | 107 ++++++++++++++++---------------- 1 file changed, 54 insertions(+), 53 deletions(-) (limited to 'runners/cli/src') diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index ae2f1136..85826fe0 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -40,59 +40,61 @@ data class GlobalArguments( override var format: String = "", override var generateIndexPages: Boolean = false, override var cacheRoot: String? = null, - override var passesConfigurations: List = listOf(), + override var passesConfigurations: List = listOf(), override var impliedPlatforms: MutableList = mutableListOf() ) : DokkaConfiguration class DokkaArgumentsParser { - private fun CommandLineInterface.registerSingleAction( - keys: List, - help: String, - invoke: (String) -> Unit - ) = registerAction( - object : FlagActionBase(keys, help) { - override fun invoke(arguments: ListIterator) { - if (arguments.hasNext()) { - val msg = arguments.next() - invoke(msg) + companion object { + fun CommandLineInterface.registerSingleAction( + keys: List, + help: String, + invoke: (String) -> Unit + ) = registerAction( + object : FlagActionBase(keys, help) { + override fun invoke(arguments: ListIterator) { + if (arguments.hasNext()) { + val msg = arguments.next() + invoke(msg) + } } - } - override fun invoke() { - error("should be never called") + override fun invoke() { + error("should be never called") + } } - } - ) - - private fun CommandLineInterface.registerRepeatingAction( - keys: List, - help: String, - invoke: (String) -> Unit - ) = registerAction( - object : FlagActionBase(keys, help) { - override fun invoke(arguments: ListIterator) { - while (arguments.hasNext()) { - val message = arguments.next() - - if (cli.getFlagAction(message) != null) { - arguments.previous() - break + ) + + fun CommandLineInterface.registerRepeatingAction( + keys: List, + help: String, + invoke: (String) -> Unit + ) = registerAction( + object : FlagActionBase(keys, help) { + override fun invoke(arguments: ListIterator) { + while (arguments.hasNext()) { + val message = arguments.next() + + if (this@registerRepeatingAction.getFlagAction(message) != null) { + arguments.previous() + break + } + invoke(message) } - invoke(message) + } + override fun invoke() { + error("should be never called") + } } - override fun invoke() { - error("should be never called") - } - } + ) - ) + } val cli = CommandLineInterface("dokka") - val passArguments = mutableListOf() val globalArguments = GlobalArguments() init { @@ -100,14 +102,14 @@ class DokkaArgumentsParser { listOf("-pass"), "Single dokka pass" ) { - passArguments += Arguments() + globalArguments.passesConfigurations += Arguments() } cli.registerRepeatingAction( listOf("-src"), "Source file or directory (allows many paths separated by the system path separator)" ) { - passArguments.last().sourceRoots.add(SourceRootImpl.parseSourceRoot(it)) + globalArguments.passesConfigurations.last().sourceRoots.add(SourceRootImpl.parseSourceRoot(it)) } cli.registerRepeatingAction( @@ -121,14 +123,14 @@ class DokkaArgumentsParser { listOf("-include"), "Markdown files to load (allows many paths separated by the system path separator)" ) { - passArguments.last().includes.add(it) + globalArguments.passesConfigurations.last().includes.add(it) } cli.registerRepeatingAction( listOf("-samples"), "Source root for samples" ) { - passArguments.last().samples.add(it) + globalArguments.passesConfigurations.last().samples.add(it) } cli.registerSingleAction( @@ -149,28 +151,28 @@ class DokkaArgumentsParser { listOf("-module"), "Name of the documentation module" ) { - passArguments.last().moduleName = it + globalArguments.passesConfigurations.last().moduleName = it } cli.registerRepeatingAction( listOf("-classpath"), "Classpath for symbol resolution" ) { - passArguments.last().classpath.add(it) + globalArguments.passesConfigurations.last().classpath.add(it) } cli.flagAction( listOf("-nodeprecacted"), "Exclude deprecated members from documentation" ) { - passArguments.last().skipDeprecated = true + globalArguments.passesConfigurations.last().skipDeprecated = true } cli.registerSingleAction( listOf("jdkVersion"), "Version of JDK to use for linking to JDK JavaDoc" ) { - passArguments.last().jdkVersion = Integer.parseInt(it) + globalArguments.passesConfigurations.last().jdkVersion = Integer.parseInt(it) } cli.registerRepeatingAction( @@ -184,28 +186,28 @@ class DokkaArgumentsParser { listOf("-pckageOptions"), "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " ) { - passArguments.last().perPackageOptions = parsePerPackageOptions(it) + globalArguments.passesConfigurations.last().perPackageOptions = parsePerPackageOptions(it) } cli.registerSingleAction( listOf("links"), "External documentation links in format url^packageListUrl^^url2..." ) { - passArguments.last().externalDocumentationLinks = MainKt.parseLinks(it) + globalArguments.passesConfigurations.last().externalDocumentationLinks = MainKt.parseLinks(it) } cli.flagAction( listOf("-noStdlibLink"), "Disable documentation link to stdlib" ) { - passArguments.last().noStdlibLink = true + globalArguments.passesConfigurations.last().noStdlibLink = true } cli.flagAction( listOf("-noJdkLink"), "Disable documentation link to jdk" ) { - passArguments.last().noJdkLink = true + globalArguments.passesConfigurations.last().noJdkLink = true } cli.registerSingleAction( @@ -219,21 +221,21 @@ class DokkaArgumentsParser { listOf("-languageVersion"), "Language Version to pass to Kotlin Analysis" ) { - passArguments.last().languageVersion = it + globalArguments.passesConfigurations.last().languageVersion = it } cli.registerSingleAction( listOf("-apiVesion"), "Kotlin Api Version to pass to Kotlin Analysis" ) { - passArguments.last().apiVersion = it + globalArguments.passesConfigurations.last().apiVersion = it } cli.flagAction( listOf("-collectInheritedExtensionsFromLibraries"), "Search for applicable extensions in libraries" ) { - passArguments.last().collectInheritedExtensionsFromLibraries = true + globalArguments.passesConfigurations.last().collectInheritedExtensionsFromLibraries = true } } @@ -241,7 +243,6 @@ class DokkaArgumentsParser { fun parse(args: Array): DokkaConfiguration { cli.parseArgs(*args) - globalArguments.passesConfigurations = passArguments return globalArguments } } -- cgit From 8d051eb3b32d7caf44b972fe03f2e0a5fcdd4490 Mon Sep 17 00:00:00 2001 From: aleksZubakov Date: Fri, 10 Aug 2018 16:12:50 +0300 Subject: Boilerplate eliminating --- .../src/main/kotlin/cli/DokkaArgumentsParser.kt | 226 +++++++++++++ runners/cli/src/main/kotlin/cli/main.kt | 376 ++++++++------------- 2 files changed, 363 insertions(+), 239 deletions(-) create mode 100644 runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt (limited to 'runners/cli/src') diff --git a/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt b/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt new file mode 100644 index 00000000..dd4d6377 --- /dev/null +++ b/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt @@ -0,0 +1,226 @@ +package org.jetbrains.dokka + +import kotlinx.cli.* +import kotlin.reflect.KProperty +class ParseContext(val cli: CommandLineInterface = CommandLineInterface("dokka")) { + private val map = mutableMapOf, (String) -> Unit>() + private val flagActions = mutableMapOf, () -> Unit>() + + fun registerFlagAction( + keys: List, + help: String, + invoke: () -> Unit, + property: KProperty<*> + ) { + if (property !in flagActions.keys) { + cli.flagAction(keys, help) { + flagActions[property]!!() + } + } + flagActions[property] = invoke + + } + + fun registerSingleAction( + keys: List, + help: String, + invoke: (String) -> Unit, + property: KProperty<*> + ) { + if (property !in map.keys) { + cli.singleAction(keys, help) { + map[property]!!(it) + } + } + map[property] = invoke + } + + fun registerRepeatableAction( + keys: List, + help: String, + invoke: (String) -> Unit, + property: KProperty<*> + ) { + if (property !in map.keys) { + cli.repeatingAction(keys, help) { + map[property]!!(it) + } + } + map[property] = invoke + } + + fun parse(args: Array) { + cli.parseArgs(*args) + } + +} + +fun CommandLineInterface.singleAction( + keys: List, + help: String, + invoke: (String) -> Unit +) = registerAction( + object : FlagActionBase(keys, help) { + override fun invoke(arguments: ListIterator) { + if (arguments.hasNext()) { + val msg = arguments.next() + invoke(msg) + } + } + + override fun invoke() { + error("should be never called") + } + } +) + +fun CommandLineInterface.repeatingAction( + keys: List, + help: String, + invoke: (String) -> Unit +) = registerAction( + object : FlagActionBase(keys, help) { + override fun invoke(arguments: ListIterator) { + while (arguments.hasNext()) { + val message = arguments.next() + + if (this@repeatingAction.getFlagAction(message) != null) { + arguments.previous() + break + } + invoke(message) + } + } + + override fun invoke() { + error("should be never called") + } + } + +) + +class DokkaArgumentsParser(val args: Array, val parseContext: ParseContext) { + fun parseInto(constructor: (parseContext: DokkaArgumentsParser) -> T): T { + val res = constructor(this) + parseContext.parse(args) + return res + } + + fun repeatableOption( + keys: List, + help: String, + transform: (String) -> T + ): OptionDelegate> { + val list = mutableListOf() + return object : OptionDelegate>(list) { + override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate> { + parseContext.registerRepeatableAction( + keys, + help, + { + list.add(transform(it)) + }, + property + + ) + return this + } + } + } + + fun repeatableFlag( + keys: List, + help: String, + initElement: (ParseContext) -> T + ): OptionDelegate> { + val list = mutableListOf() + return object : OptionDelegate>(list) { + override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate> { + parseContext.registerFlagAction( + keys, + help, + { + list.add(initElement(parseContext)) + }, + property + + ) + return this + } + } + } + + fun singleFlag( + keys: List, + help: String, + initElement: (ParseContext) -> T, + transform: () -> T + ): OptionDelegate { + val element = initElement(parseContext) + return object : OptionDelegate(element) { + override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate { + parseContext.registerFlagAction( + keys, + help, + { + value = transform() + }, + property + ) + + return this + } + } + + } + + fun singleOption( + keys: List, + help: String, + transform: ((String) -> T)? = null, + initElement: (ParseContext) -> T + ): OptionDelegate { + val element: T = initElement(parseContext) + return object : OptionDelegate(element) { + + override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate { + parseContext.registerSingleAction( + keys, + help, + { + val toAdd = if (transform != null) { + transform(it) + } else { + it as T + } + value = toAdd + }, + property + ) + + return this + } + } + } + + fun singleBooleanFlag( + keys: List, + help: String + ) = singleFlag(keys, help, { false }, { true }) + + fun defaultSingleOption( + keys: List, + help: String, + defaultValue: T + ) = singleOption( + keys, + help, + { it as T }, + { defaultValue } + ) +} + +abstract class OptionDelegate(var value: T) { + operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value + abstract operator fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate +} diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 85826fe0..34d86257 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 kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import java.io.File @@ -8,247 +7,144 @@ import java.net.MalformedURLException import java.net.URL import java.net.URLClassLoader -data class Arguments( - override var moduleName: String = "", - override var classpath: MutableList = mutableListOf(), - override var sourceRoots: MutableList = mutableListOf(), - override var samples: MutableList = mutableListOf(), - override var includes: MutableList = mutableListOf(), - override var includeNonPublic: Boolean = false, - override var includeRootPackage: Boolean = false, - override var reportUndocumented: Boolean = false, - override var skipEmptyPackages: Boolean = false, - override var skipDeprecated: Boolean = false, - override var jdkVersion: Int = 6, - override var sourceLinks: List = listOf(), - override var perPackageOptions: List = listOf(), - override var externalDocumentationLinks: List = listOf(), - override var languageVersion: String? = "", - override var apiVersion: String? = "", - override var noStdlibLink: Boolean = false, - override var noJdkLink: Boolean = false, - override var suppressedFiles: MutableList = mutableListOf(), - override var collectInheritedExtensionsFromLibraries: Boolean = false, - override var analysisPlatform: Platform = Platform.DEFAULT, - override var targets: MutableList = mutableListOf(), - var rawPerPackageOptions: MutableList = mutableListOf() -) : DokkaConfiguration.PassConfiguration - - -data class GlobalArguments( - override var outputDir: String = "", - override var format: String = "", - override var generateIndexPages: Boolean = false, - override var cacheRoot: String? = null, - override var passesConfigurations: List = listOf(), - override var impliedPlatforms: MutableList = mutableListOf() -) : DokkaConfiguration - -class DokkaArgumentsParser { - companion object { - fun CommandLineInterface.registerSingleAction( - keys: List, - help: String, - invoke: (String) -> Unit - ) = registerAction( - object : FlagActionBase(keys, help) { - override fun invoke(arguments: ListIterator) { - if (arguments.hasNext()) { - val msg = arguments.next() - invoke(msg) - } - } - - override fun invoke() { - error("should be never called") - } - } - - ) - - fun CommandLineInterface.registerRepeatingAction( - keys: List, - help: String, - invoke: (String) -> Unit - ) = registerAction( - object : FlagActionBase(keys, help) { - override fun invoke(arguments: ListIterator) { - while (arguments.hasNext()) { - val message = arguments.next() - - if (this@registerRepeatingAction.getFlagAction(message) != null) { - arguments.previous() - break - } - invoke(message) - } - - } - - override fun invoke() { - error("should be never called") - } - } - - ) - - } - - val cli = CommandLineInterface("dokka") - val globalArguments = GlobalArguments() - - init { - cli.flagAction( - listOf("-pass"), - "Single dokka pass" - ) { - globalArguments.passesConfigurations += Arguments() - } - - cli.registerRepeatingAction( - listOf("-src"), - "Source file or directory (allows many paths separated by the system path separator)" - ) { - globalArguments.passesConfigurations.last().sourceRoots.add(SourceRootImpl.parseSourceRoot(it)) - } - - cli.registerRepeatingAction( - listOf("-srcLink"), - "Mapping between a source directory and a Web site for browsing the code" - ) { - println(it) - } - - cli.registerRepeatingAction( - listOf("-include"), - "Markdown files to load (allows many paths separated by the system path separator)" - ) { - globalArguments.passesConfigurations.last().includes.add(it) - } - - cli.registerRepeatingAction( - listOf("-samples"), - "Source root for samples" - ) { - globalArguments.passesConfigurations.last().samples.add(it) - } - - cli.registerSingleAction( - listOf("-output"), - "Output directory path" - ) { - globalArguments.outputDir = it - } - - cli.registerSingleAction( - listOf("-format"), - "Output format (text, html, markdown, jekyll, kotlin-website)" - ) { - globalArguments.format = it - } - - cli.registerSingleAction( - listOf("-module"), - "Name of the documentation module" - ) { - globalArguments.passesConfigurations.last().moduleName = it - } - - cli.registerRepeatingAction( - listOf("-classpath"), - "Classpath for symbol resolution" - ) { - globalArguments.passesConfigurations.last().classpath.add(it) - } - - cli.flagAction( - listOf("-nodeprecacted"), - "Exclude deprecated members from documentation" - ) { - globalArguments.passesConfigurations.last().skipDeprecated = true - } - - cli.registerSingleAction( - listOf("jdkVersion"), - "Version of JDK to use for linking to JDK JavaDoc" - ) { - globalArguments.passesConfigurations.last().jdkVersion = Integer.parseInt(it) - } - - cli.registerRepeatingAction( - listOf("-impliedPlatforms"), - "List of implied platforms (comma-separated)" - ) { - globalArguments.impliedPlatforms.add(it) - } - - cli.registerSingleAction( - listOf("-pckageOptions"), - "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " - ) { - globalArguments.passesConfigurations.last().perPackageOptions = parsePerPackageOptions(it) - } - - cli.registerSingleAction( - listOf("links"), - "External documentation links in format url^packageListUrl^^url2..." - ) { - globalArguments.passesConfigurations.last().externalDocumentationLinks = MainKt.parseLinks(it) - } - - cli.flagAction( - listOf("-noStdlibLink"), - "Disable documentation link to stdlib" - ) { - globalArguments.passesConfigurations.last().noStdlibLink = true - } - - cli.flagAction( - listOf("-noJdkLink"), - "Disable documentation link to jdk" - ) { - globalArguments.passesConfigurations.last().noJdkLink = true - } - - cli.registerSingleAction( - listOf("-cacheRoot"), - "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled" - ) { - globalArguments.cacheRoot = it - } - - cli.registerSingleAction( - listOf("-languageVersion"), - "Language Version to pass to Kotlin Analysis" - ) { - globalArguments.passesConfigurations.last().languageVersion = it - } - - cli.registerSingleAction( - listOf("-apiVesion"), - "Kotlin Api Version to pass to Kotlin Analysis" - ) { - globalArguments.passesConfigurations.last().apiVersion = it - } - - cli.flagAction( - listOf("-collectInheritedExtensionsFromLibraries"), - "Search for applicable extensions in libraries" - ) { - globalArguments.passesConfigurations.last().collectInheritedExtensionsFromLibraries = true - } - +open class GlobalArguments(parser: DokkaArgumentsParser) : DokkaConfiguration { + override val outputDir: String by parser.defaultSingleOption( + listOf("-output"), + "Output directory path", + "") + + override val format: String by parser.defaultSingleOption( + listOf("-format"), + "Output format (text, html, markdown, jekyll, kotlin-website)", + "") + + override val generateIndexPages: Boolean by parser.singleBooleanFlag( + listOf("-generateIndexPages"), + "Generate index page" + ) + + override val cacheRoot: String? by parser.defaultSingleOption( + listOf("-cacheRoot"), + "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled", + null) + + override val impliedPlatforms: List by parser.repeatableOption( + listOf("-impliedPlatforms"), + "List of implied platforms (comma-separated)" + ) { it } + + override val passesConfigurations: List by parser.repeatableFlag( + listOf("-pass"), + "Single dokka pass" + ) { + Arguments(parser) } +} - fun parse(args: Array): DokkaConfiguration { - cli.parseArgs(*args) - - return globalArguments - } +class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfiguration { + override val moduleName: String by parser.defaultSingleOption( + listOf("-module"), + "Name of the documentation module", + "") + + override val classpath: List by parser.repeatableOption( + listOf("-classpath"), + "Classpath for symbol resolution" + ) { it } + + override val sourceRoots: List by parser.repeatableOption( + listOf("-src"), + "Source file or directory (allows many paths separated by the system path separator)" + ) { SourceRootImpl.parseSourceRoot(it) } + + override val samples: List by parser.repeatableOption( + listOf("-samples"), + "Source root for samples" + ) { it } + + override val includes: List by parser.repeatableOption( + listOf("-include"), + "Markdown files to load (allows many paths separated by the system path separator)" + ) { it } + + override val includeNonPublic: Boolean by parser.singleBooleanFlag( + listOf("-includeNonPublic"), + "Include non public") + + override val includeRootPackage: Boolean by parser.singleBooleanFlag( + listOf("-includeRootPackage"), + "Include non public") + + override val reportUndocumented: Boolean by parser.singleBooleanFlag( + listOf("-reportUndocumented"), + "Include non public") + + override val skipEmptyPackages: Boolean by parser.singleBooleanFlag( + listOf("-skipEmptyPackages"), + "Include non public") + + override val skipDeprecated: Boolean by parser.singleBooleanFlag( + listOf("-skipDeprecated"), + "Include non public") + + override val jdkVersion: Int by parser.singleOption( + listOf("jdkVersion"), + "Version of JDK to use for linking to JDK JavaDoc", + { it.toInt() }, + { 6 } + ) + + override val languageVersion: String? by parser.defaultSingleOption( + listOf("-languageVersion"), + "Language Version to pass to Kotlin Analysis", + null) + + override val apiVersion: String? by parser.defaultSingleOption( + listOf("-apiVesion"), + "Kotlin Api Version to pass to Kotlin Analysis", + null + ) + + override val noStdlibLink: Boolean by parser.singleBooleanFlag( + listOf("-noStdlibLink"), + "Disable documentation link to stdlib") + + override val noJdkLink: Boolean by parser.singleBooleanFlag( + listOf("-noJdkLink"), + "Disable documentation link to stdlib") + + override val suppressedFiles: List by parser.repeatableOption( + listOf("-suppresedFiles"), + "", + { it } + ) + + override val collectInheritedExtensionsFromLibraries: Boolean by parser.singleBooleanFlag( + listOf("-collectInheritedExtensionsFromLibraries"), + "Search for applicable extensions in libraries") + + override val analysisPlatform: Platform by parser.singleOption( + listOf("-analysisPlatform"), + "Platform for analysis", + { Platform.fromString(it) }, + { Platform.DEFAULT } + ) + + override val targets: List by parser.repeatableOption( + listOf("-targets"), + "Generation targets", + { it } + ) + + override val sourceLinks: List + get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates. + override val perPackageOptions: List + get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates. + override val externalDocumentationLinks: List + get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates. } object MainKt { - fun parseLinks(links: String): List { val (parsedLinks, parsedOfflineLinks) = links.split("^^") .map { it.split("^").map { it.trim() }.filter { it.isNotBlank() } } @@ -312,8 +208,10 @@ object MainKt { fun main(args: Array) { - val dokkaArgumentsParser = DokkaArgumentsParser() - val configuration = dokkaArgumentsParser.parse(args) + val parser = DokkaArgumentsParser(args, ParseContext()) + val parseContext = parser.parseInto(::GlobalArguments) + + val configuration = parseContext if (configuration.format == "javadoc") startWithToolsJar(configuration) -- cgit From 696598260072fea2329db9140f9635b87033c478 Mon Sep 17 00:00:00 2001 From: aleksZubakov Date: Sat, 11 Aug 2018 16:59:31 +0300 Subject: Cli parser refactoring --- .../src/main/kotlin/cli/DokkaArgumentsParser.kt | 160 ++++++++------------- runners/cli/src/main/kotlin/cli/main.kt | 44 +++--- 2 files changed, 78 insertions(+), 126 deletions(-) (limited to 'runners/cli/src') diff --git a/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt b/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt index dd4d6377..7b8f5fa0 100644 --- a/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt +++ b/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt @@ -2,15 +2,16 @@ package org.jetbrains.dokka import kotlinx.cli.* import kotlin.reflect.KProperty -class ParseContext(val cli: CommandLineInterface = CommandLineInterface("dokka")) { - private val map = mutableMapOf, (String) -> Unit>() + +class ParseContext(private val cli: CommandLineInterface = CommandLineInterface("dokka")) { + private val transformActions = mutableMapOf, (String) -> Unit>() private val flagActions = mutableMapOf, () -> Unit>() fun registerFlagAction( keys: List, help: String, - invoke: () -> Unit, - property: KProperty<*> + property: KProperty<*>, + invoke: () -> Unit ) { if (property !in flagActions.keys) { cli.flagAction(keys, help) { @@ -21,32 +22,32 @@ class ParseContext(val cli: CommandLineInterface = CommandLineInterface("dokka") } - fun registerSingleAction( + fun registerSingleOption( keys: List, help: String, - invoke: (String) -> Unit, - property: KProperty<*> + property: KProperty<*>, + invoke: (String) -> Unit ) { - if (property !in map.keys) { + if (property !in transformActions.keys) { cli.singleAction(keys, help) { - map[property]!!(it) + transformActions[property]!!(it) } } - map[property] = invoke + transformActions[property] = invoke } - fun registerRepeatableAction( + fun registerRepeatableOption( keys: List, help: String, - invoke: (String) -> Unit, - property: KProperty<*> + property: KProperty<*>, + invoke: (String) -> Unit ) { - if (property !in map.keys) { + if (property !in transformActions.keys) { cli.repeatingAction(keys, help) { - map[property]!!(it) + transformActions[property]!!(it) } } - map[property] = invoke + transformActions[property] = invoke } fun parse(args: Array) { @@ -99,7 +100,19 @@ fun CommandLineInterface.repeatingAction( ) + class DokkaArgumentsParser(val args: Array, val parseContext: ParseContext) { + class OptionDelegate( + var value: T, + private val action: (delegate: OptionDelegate, property: KProperty<*>) -> Unit + ) { + operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value + operator fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate { + action(this, property) + return this + } + } + fun parseInto(constructor: (parseContext: DokkaArgumentsParser) -> T): T { val res = constructor(this) parseContext.parse(args) @@ -110,43 +123,24 @@ class DokkaArgumentsParser(val args: Array, val parseContext: ParseConte keys: List, help: String, transform: (String) -> T - ): OptionDelegate> { - val list = mutableListOf() - return object : OptionDelegate>(list) { - override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate> { - parseContext.registerRepeatableAction( - keys, - help, - { - list.add(transform(it)) - }, - property - - ) - return this - } + ) = OptionDelegate(mutableListOf()) { delegate, property -> + parseContext.registerRepeatableOption(keys, help, property) { + delegate.value.add(transform(it)) } } + fun repeatableOption( + keys: List, + help: String + ) = repeatableOption(keys, help) { it as T } + fun repeatableFlag( keys: List, help: String, initElement: (ParseContext) -> T - ): OptionDelegate> { - val list = mutableListOf() - return object : OptionDelegate>(list) { - override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate> { - parseContext.registerFlagAction( - keys, - help, - { - list.add(initElement(parseContext)) - }, - property - - ) - return this - } + ) = OptionDelegate(mutableListOf()) { delegate, property -> + parseContext.registerFlagAction(keys, help, property) { + delegate.value.add(initElement(parseContext)) } } @@ -155,72 +149,32 @@ class DokkaArgumentsParser(val args: Array, val parseContext: ParseConte help: String, initElement: (ParseContext) -> T, transform: () -> T - ): OptionDelegate { - val element = initElement(parseContext) - return object : OptionDelegate(element) { - override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate { - parseContext.registerFlagAction( - keys, - help, - { - value = transform() - }, - property - ) - - return this - } - } - - } - - fun singleOption( - keys: List, - help: String, - transform: ((String) -> T)? = null, - initElement: (ParseContext) -> T - ): OptionDelegate { - val element: T = initElement(parseContext) - return object : OptionDelegate(element) { - - override fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate { - parseContext.registerSingleAction( - keys, - help, - { - val toAdd = if (transform != null) { - transform(it) - } else { - it as T - } - value = toAdd - }, - property - ) - - return this - } + ) = OptionDelegate(initElement(parseContext)) { delegate, property -> + parseContext.registerFlagAction(keys, help, property) { + delegate.value = transform() } } - fun singleBooleanFlag( + fun singleFlag( keys: List, help: String ) = singleFlag(keys, help, { false }, { true }) - fun defaultSingleOption( + fun singleOption( keys: List, help: String, defaultValue: T - ) = singleOption( - keys, - help, - { it as T }, - { defaultValue } - ) -} + ) = singleOption(keys, help, { it as T }, { defaultValue }) -abstract class OptionDelegate(var value: T) { - operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value - abstract operator fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate + fun singleOption( + keys: List, + help: String, + transform: (String) -> T, + initElement: (ParseContext) -> T + ) = OptionDelegate(initElement(parseContext)) { delegate, property -> + parseContext.registerSingleOption(keys, help, property) { + val toAdd = transform(it) + delegate.value = toAdd + } + } } diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 34d86257..0e17c193 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -8,22 +8,22 @@ import java.net.URL import java.net.URLClassLoader open class GlobalArguments(parser: DokkaArgumentsParser) : DokkaConfiguration { - override val outputDir: String by parser.defaultSingleOption( + override val outputDir: String by parser.singleOption( listOf("-output"), "Output directory path", "") - override val format: String by parser.defaultSingleOption( + override val format: String by parser.singleOption( listOf("-format"), "Output format (text, html, markdown, jekyll, kotlin-website)", "") - override val generateIndexPages: Boolean by parser.singleBooleanFlag( + override val generateIndexPages: Boolean by parser.singleFlag( listOf("-generateIndexPages"), "Generate index page" ) - override val cacheRoot: String? by parser.defaultSingleOption( + override val cacheRoot: String? by parser.singleOption( listOf("-cacheRoot"), "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled", null) @@ -31,7 +31,7 @@ open class GlobalArguments(parser: DokkaArgumentsParser) : DokkaConfiguration { override val impliedPlatforms: List by parser.repeatableOption( listOf("-impliedPlatforms"), "List of implied platforms (comma-separated)" - ) { it } + ) override val passesConfigurations: List by parser.repeatableFlag( listOf("-pass"), @@ -42,7 +42,7 @@ open class GlobalArguments(parser: DokkaArgumentsParser) : DokkaConfiguration { } class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfiguration { - override val moduleName: String by parser.defaultSingleOption( + override val moduleName: String by parser.singleOption( listOf("-module"), "Name of the documentation module", "") @@ -50,7 +50,7 @@ class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfi override val classpath: List by parser.repeatableOption( listOf("-classpath"), "Classpath for symbol resolution" - ) { it } + ) override val sourceRoots: List by parser.repeatableOption( listOf("-src"), @@ -60,30 +60,30 @@ class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfi override val samples: List by parser.repeatableOption( listOf("-samples"), "Source root for samples" - ) { it } + ) override val includes: List by parser.repeatableOption( listOf("-include"), "Markdown files to load (allows many paths separated by the system path separator)" - ) { it } + ) - override val includeNonPublic: Boolean by parser.singleBooleanFlag( + override val includeNonPublic: Boolean by parser.singleFlag( listOf("-includeNonPublic"), "Include non public") - override val includeRootPackage: Boolean by parser.singleBooleanFlag( + override val includeRootPackage: Boolean by parser.singleFlag( listOf("-includeRootPackage"), "Include non public") - override val reportUndocumented: Boolean by parser.singleBooleanFlag( + override val reportUndocumented: Boolean by parser.singleFlag( listOf("-reportUndocumented"), "Include non public") - override val skipEmptyPackages: Boolean by parser.singleBooleanFlag( + override val skipEmptyPackages: Boolean by parser.singleFlag( listOf("-skipEmptyPackages"), "Include non public") - override val skipDeprecated: Boolean by parser.singleBooleanFlag( + override val skipDeprecated: Boolean by parser.singleFlag( listOf("-skipDeprecated"), "Include non public") @@ -94,32 +94,31 @@ class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfi { 6 } ) - override val languageVersion: String? by parser.defaultSingleOption( + override val languageVersion: String? by parser.singleOption( listOf("-languageVersion"), "Language Version to pass to Kotlin Analysis", null) - override val apiVersion: String? by parser.defaultSingleOption( + override val apiVersion: String? by parser.singleOption( listOf("-apiVesion"), "Kotlin Api Version to pass to Kotlin Analysis", null ) - override val noStdlibLink: Boolean by parser.singleBooleanFlag( + override val noStdlibLink: Boolean by parser.singleFlag( listOf("-noStdlibLink"), "Disable documentation link to stdlib") - override val noJdkLink: Boolean by parser.singleBooleanFlag( + override val noJdkLink: Boolean by parser.singleFlag( listOf("-noJdkLink"), "Disable documentation link to stdlib") override val suppressedFiles: List by parser.repeatableOption( listOf("-suppresedFiles"), - "", - { it } + "" ) - override val collectInheritedExtensionsFromLibraries: Boolean by parser.singleBooleanFlag( + override val collectInheritedExtensionsFromLibraries: Boolean by parser.singleFlag( listOf("-collectInheritedExtensionsFromLibraries"), "Search for applicable extensions in libraries") @@ -132,8 +131,7 @@ class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfi override val targets: List by parser.repeatableOption( listOf("-targets"), - "Generation targets", - { it } + "Generation targets" ) override val sourceLinks: List -- cgit From b67828585356db1cf0ac95a1a1291a7bf2d78684 Mon Sep 17 00:00:00 2001 From: Zubakov Aleksey