From b1520f0a45e5102f77a43dd20746a3db047bbcf4 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Tue, 16 Jun 2020 15:35:17 +0200 Subject: Implement default configurations --- .gitignore | 2 ++ .idea/compiler.xml | 23 ------------- .idea/misc.xml | 9 ----- core/src/main/kotlin/DokkaBootstrapImpl.kt | 24 ++++++++++--- core/src/main/kotlin/configuration.kt | 27 +++++++++++++-- runners/cli/src/main/kotlin/cli/main.kt | 27 +++++++-------- .../dokka/gradle/configurationImplementations.kt | 35 +++++++++---------- runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 39 +++++++++++----------- 8 files changed, 96 insertions(+), 90 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/misc.xml diff --git a/.gitignore b/.gitignore index 78a59f54..13060d89 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,8 @@ hs_err_pid* .idea/shelf .idea/jsLibraryMappings.xml .idea/modules.xml +.idea/misc.xml +.idea/compiler.xml # Sensitive or high-churn files: .idea/dataSources.ids diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index a6b0adf4..00000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index ff8249e4..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index e0f014c8..32248163 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -11,12 +11,26 @@ import java.util.function.BiConsumer 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") + 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 + + val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") + ?: args.find { it.endsWith("skipDeprecated") }?.startsWith("+") + ?: DokkaDefaults.skipDeprecated + + val reportUndocumented = args.find { it.endsWith("reportUndocumented") }?.startsWith("+") + ?: DokkaDefaults.reportUndocumented + + val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") + ?: args.find { it.endsWith("includeNonPublic") }?.startsWith("+") + ?: DokkaDefaults.includeNonPublic + + val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") + ?:DokkaDefaults.suppress + PackageOptionsImpl( prefix, includeNonPublic = privateApi, diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index f5115435..b016f83d 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -3,6 +3,25 @@ package org.jetbrains.dokka import java.io.File import java.net.URL +object DokkaDefaults { + const val outputDir = "./dokka" + const val format: String = "html" + val cacheRoot: String? = null + const val offlineMode: Boolean = false + const val failOnWarning: Boolean = false + + const val includeNonPublic: Boolean = false + const val includeRootPackage: Boolean = false + const val reportUndocumented: Boolean = false + const val skipEmptyPackages: Boolean = false + const val skipDeprecated: Boolean = false + const val jdkVersion: Int = 8 + const val noStdlibLink: Boolean = false + const val noJdkLink: Boolean = false + val analysisPlatform: Platform = Platform.DEFAULT + const val suppress: Boolean = false +} + enum class Platform(val key: String) { jvm("jvm"), js("js"), @@ -29,11 +48,11 @@ interface DokkaConfiguration { val format: String val cacheRoot: String? val offlineMode: Boolean + val failOnWarning: Boolean val passesConfigurations: List val modules: List val pluginsClasspath: List val pluginsConfiguration: Map - val failOnWarning: Boolean interface PassConfiguration { val moduleName: String @@ -89,8 +108,10 @@ interface DokkaConfiguration { val url: URL val packageListUrl: URL - open class Builder(open var url: URL? = null, - open var packageListUrl: URL? = null) { + open class Builder( + open var url: URL? = null, + open var packageListUrl: URL? = null + ) { constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) }) diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 515f9bb0..f0df08e0 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -3,6 +3,7 @@ package org.jetbrains.dokka import com.google.gson.Gson import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink +import org.jetbrains.dokka.DokkaConfiguration.PassConfiguration.* import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.kotlin.utils.addToStdlib.cast import java.io.* @@ -18,12 +19,12 @@ class GlobalArguments(args: Array) : DokkaConfiguration { val json: String? by parser.argument(ArgType.String, description = "Json file name").optional() override val outputDir by parser.option(ArgType.String, description = "Output directory path") - .default("./dokka") + .default(DokkaDefaults.outputDir) override val format by parser.option( ArgType.String, description = "Output format (html, gfm, jekyll)" - ).default("html") + ).default(DokkaDefaults.format) override val cacheRoot by parser.option( ArgType.String, @@ -50,12 +51,12 @@ class GlobalArguments(args: Array) : DokkaConfiguration { override val offlineMode by parser.option( ArgType.Boolean, "Offline mode (do not download package lists from the Internet)" - ).default(false) + ).default(DokkaDefaults.offlineMode) override val failOnWarning by parser.option( ArgType.Boolean, "Throw an exception if the generation exited with warnings" - ).default(false) + ).default(DokkaDefaults.failOnWarning) val globalPackageOptions by parser.option( ArgType.String, @@ -160,26 +161,26 @@ fun passArguments(args: Array): DokkaConfiguration.PassConfiguration { ).delimiter(";") val includeNonPublic: Boolean by parser.option(ArgType.Boolean, description = "Include non public") - .default(false) + .default(DokkaDefaults.includeNonPublic) val includeRootPackage by parser.option(ArgType.Boolean, description = "Include non public") - .default(false) + .default(DokkaDefaults.includeRootPackage) val reportUndocumented by parser.option(ArgType.Boolean, description = "Report undocumented members") - .default(false) + .default(DokkaDefaults.reportUndocumented) val skipEmptyPackages by parser.option( ArgType.Boolean, description = "Do not create index pages for empty packages" - ).default(false) + ).default(DokkaDefaults.skipEmptyPackages) val skipDeprecated by parser.option(ArgType.Boolean, description = "Do not output deprecated members") - .default(false) + .default(DokkaDefaults.skipDeprecated) val jdkVersion by parser.option( ArgType.Int, description = "Version of JDK to use for linking to JDK JavaDoc" - ).default(8) + ).default(DokkaDefaults.jdkVersion) val languageVersion by parser.option( ArgType.String, @@ -192,10 +193,10 @@ fun passArguments(args: Array): DokkaConfiguration.PassConfiguration { ) val noStdlibLink by parser.option(ArgType.Boolean, description = "Disable documentation link to stdlib") - .default(false) + .default(DokkaDefaults.noStdlibLink) val noJdkLink by parser.option(ArgType.Boolean, description = "Disable documentation link to JDK") - .default(false) + .default(DokkaDefaults.noJdkLink) val suppressedFiles by parser.option( ArgType.String, @@ -205,7 +206,7 @@ fun passArguments(args: Array): DokkaConfiguration.PassConfiguration { val analysisPlatform: Platform by parser.option( ArgTypePlatform, description = "Platform for analysis" - ).default(Platform.DEFAULT) + ).default(DokkaDefaults.analysisPlatform) val perPackageOptions by parser.option( ArgType.String, diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt index 152fa910..f4e7730e 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt @@ -7,6 +7,7 @@ import org.gradle.api.tasks.Optional import org.gradle.util.ConfigureUtil import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaConfiguration.* +import org.jetbrains.dokka.DokkaDefaults import org.jetbrains.dokka.Platform import java.io.File import java.io.Serializable @@ -33,22 +34,22 @@ open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassCo @Input override var dependentSourceSets: MutableList = mutableListOf() @Input override var samples: List = emptyList() @Input override var includes: List = emptyList() - @Input override var includeNonPublic: Boolean = false - @Input override var includeRootPackage: Boolean = false - @Input override var reportUndocumented: Boolean = false - @Input override var skipEmptyPackages: Boolean = false - @Input override var skipDeprecated: Boolean = false - @Input override var jdkVersion: Int = 8 + @Input override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + @Input override var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage + @Input override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + @Input override var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages + @Input override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Input override var jdkVersion: Int = DokkaDefaults.jdkVersion @Input override var sourceLinks: MutableList = mutableListOf() @Input override var perPackageOptions: MutableList = mutableListOf() @Input override var externalDocumentationLinks: MutableList = mutableListOf() @Input @Optional override var languageVersion: String? = null @Input @Optional override var apiVersion: String? = null - @Input override var noStdlibLink: Boolean = false - @Input override var noJdkLink: Boolean = false + @Input override var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink + @Input override var noJdkLink: Boolean = DokkaDefaults.noJdkLink @Input var noAndroidSdkLink: Boolean = false @Input override var suppressedFiles: List = emptyList() - @Input override var analysisPlatform: Platform = Platform.DEFAULT + @Input override var analysisPlatform: Platform = DokkaDefaults.analysisPlatform @Input @Optional var platform: String? = null @Transient var collectKotlinTasks: (() -> List?)? = null @@ -124,22 +125,22 @@ class GradleDokkaModuleDescription: DokkaModuleDescription { class GradleDokkaConfigurationImpl: DokkaConfiguration { override var outputDir: String = "" - override var format: String = "html" - override var cacheRoot: String? = null - override var offlineMode: Boolean = false + override var format: String = DokkaDefaults.format + override var cacheRoot: String? = DokkaDefaults.cacheRoot + override var offlineMode: Boolean = DokkaDefaults.offlineMode + override var failOnWarning: Boolean = DokkaDefaults.failOnWarning override var passesConfigurations: List = emptyList() override var pluginsClasspath: List = emptyList() override var pluginsConfiguration: Map = mutableMapOf() override var modules: List = emptyList() - override var failOnWarning: Boolean = false } class GradlePackageOptionsImpl: PackageOptions, Serializable { override var prefix: String = "" - override var includeNonPublic: Boolean = false - override var reportUndocumented: Boolean = true - override var skipDeprecated: Boolean = true - override var suppress: Boolean = false + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + override var suppress: Boolean = DokkaDefaults.suppress } internal fun GradlePassConfigurationImpl.copy(): GradlePassConfigurationImpl { diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 5a739d5e..1ef04772 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -29,6 +29,7 @@ import org.eclipse.aether.transport.file.FileTransporterFactory import org.eclipse.aether.transport.http.HttpTransporterFactory import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator import org.jetbrains.dokka.* +import org.jetbrains.dokka.DokkaConfiguration.PackageOptions import java.io.File import java.net.URL @@ -69,16 +70,16 @@ abstract class AbstractDokkaMojo : AbstractMojo() { override var prefix: String = "" @Parameter - override var includeNonPublic: Boolean = false + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic @Parameter - override var reportUndocumented: Boolean = true + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented @Parameter - override var skipDeprecated: Boolean = false + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated @Parameter - override var suppress: Boolean = false + override var suppress: Boolean = DokkaDefaults.suppress } @Parameter(required = true, defaultValue = "\${project.sourceSet}") @@ -90,7 +91,6 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter var sourceRoots: List = emptyList() - @Parameter var dependentSourceSets: List = emptyList() @@ -112,17 +112,17 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter(required = false, defaultValue = "false") var skip: Boolean = false - @Parameter(required = false, defaultValue = "6") - var jdkVersion: Int = 8 + @Parameter(required = false, defaultValue = "${DokkaDefaults.jdkVersion}") + var jdkVersion: Int = DokkaDefaults.jdkVersion @Parameter - var skipDeprecated: Boolean = false + var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated @Parameter - var skipEmptyPackages: Boolean = true + var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages @Parameter - var reportUndocumented: Boolean = true + var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented @Parameter var impliedPlatforms: List = emptyList() @@ -133,11 +133,11 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter var externalDocumentationLinks: List = emptyList() - @Parameter(defaultValue = "false") - var noStdlibLink: Boolean = false + @Parameter(defaultValue = "${DokkaDefaults.noStdlibLink}") + var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink - @Parameter(defaultValue = "false") - var noJdkLink: Boolean = false + @Parameter(defaultValue = "${DokkaDefaults.noJdkLink}") + var noJdkLink: Boolean = DokkaDefaults.noJdkLink @Parameter var cacheRoot: String? = null @@ -145,8 +145,8 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter(defaultValue = "JVM") var displayName: String = "JVM" - @Parameter(defaultValue = "false") - var offlineMode: Boolean = false + @Parameter(defaultValue = "${DokkaDefaults.offlineMode}") + var offlineMode: Boolean = DokkaDefaults.offlineMode @Parameter var languageVersion: String? = null @@ -155,20 +155,19 @@ abstract class AbstractDokkaMojo : AbstractMojo() { var apiVersion: String? = null @Parameter - var includeRootPackage: Boolean = false + var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage @Parameter var suppressedFiles: List = emptyList() - @Parameter var platform: String = "" @Parameter - var includeNonPublic: Boolean = false + var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic @Parameter - var failOnWarning: Boolean = false + var failOnWarning: Boolean = DokkaDefaults.failOnWarning @Parameter var dokkaPlugins: List = emptyList() -- cgit