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 --- core/src/main/kotlin/DokkaBootstrapImpl.kt | 24 +++++++++++++++++++----- core/src/main/kotlin/configuration.kt | 27 ++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) (limited to 'core/src/main') 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) }) -- cgit