From 9637ec0747815181d56fa53419d4f6c56705752b Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Tue, 12 May 2020 15:19:53 +0200 Subject: Refactor CLI --- core/src/main/kotlin/DokkaBootstrapImpl.kt | 41 ++++++++++++-------------- core/src/main/kotlin/utilities/DokkaLogging.kt | 4 +-- 2 files changed, 21 insertions(+), 24 deletions(-) (limited to 'core/src/main') diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index d39ee1d5..e0f014c8 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -8,28 +8,25 @@ import org.jetbrains.dokka.utilities.DokkaLogger import java.util.function.BiConsumer -fun parsePerPackageOptions(arg: String): List { - if (arg.isBlank()) return emptyList() - - return arg.split(";").map { it.split(",") }.map { - val prefix = it.first() - if (prefix == "") - throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead") - val args = it.subList(1, it.size) - val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true - val reportUndocumented = args.find { it.endsWith("reportUndocumented") }?.startsWith("+") ?: true - val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false - val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") ?: false - PackageOptionsImpl( - prefix, - includeNonPublic = privateApi, - reportUndocumented = reportUndocumented, - skipDeprecated = !deprecated, - suppress = suppress - ) - } +fun parsePerPackageOptions(args: List): List = args.map { it.split(",") }.map { + val prefix = it.first() + if (prefix == "") + throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead") + val args = it.subList(1, it.size) + val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true + val reportUndocumented = args.find { it.endsWith("reportUndocumented") }?.startsWith("+") ?: true + val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false + val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") ?: false + PackageOptionsImpl( + prefix, + includeNonPublic = privateApi, + reportUndocumented = reportUndocumented, + skipDeprecated = !deprecated, + suppress = suppress + ) } + class DokkaBootstrapImpl : DokkaBootstrap { class DokkaProxyLogger(val consumer: BiConsumer) : DokkaLogger { @@ -60,9 +57,9 @@ class DokkaBootstrapImpl : DokkaBootstrap { if (warningsCount > 0 || errorsCount > 0) { println( "Generation completed with $warningsCount warning" + - (if (DokkaConsoleLogger.warningsCount == 1) "" else "s") + + (if (warningsCount == 1) "" else "s") + " and $errorsCount error" + - if (DokkaConsoleLogger.errorsCount == 1) "" else "s" + if (errorsCount == 1) "" else "s" ) } else { println("generation completed successfully") diff --git a/core/src/main/kotlin/utilities/DokkaLogging.kt b/core/src/main/kotlin/utilities/DokkaLogging.kt index 1c05c95d..4b671f7b 100644 --- a/core/src/main/kotlin/utilities/DokkaLogging.kt +++ b/core/src/main/kotlin/utilities/DokkaLogging.kt @@ -27,9 +27,9 @@ object DokkaConsoleLogger : DokkaLogger { override fun report() { if (warningsCount > 0 || errorsCount > 0) { - println("Generation completed with warningsCount warning" + + println("Generation completed with $warningsCount warning" + (if(warningsCount == 1) "" else "s") + - " and errorsCount error" + + " and $errorsCount error" + if(errorsCount == 1) "" else "s" ) } else { -- cgit