aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/DokkaBootstrapImpl.kt
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/DokkaBootstrapImpl.kt')
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt90
1 files changed, 60 insertions, 30 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
index b48b62d4..fabbc889 100644
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt
@@ -1,49 +1,78 @@
package org.jetbrains.dokka
-import com.google.gson.Gson
import org.jetbrains.dokka.DokkaConfiguration.PackageOptions
+import org.jetbrains.dokka.utilities.DokkaLogger
import java.util.function.BiConsumer
-fun parsePerPackageOptions(arg: String): List<PackageOptions> {
- if (arg.isBlank()) return emptyList()
+fun parsePerPackageOptions(args: List<String>): List<PackageOptions> = 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"
+ )
- 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("warnUndocumented") }?.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)
- }
+ val args = it.subList(1, it.size)
+
+ val deprecated = args.find { it.endsWith("skipDeprecated") }?.startsWith("+")
+ ?: DokkaDefaults.skipDeprecated
+
+ val reportUndocumented = args.find { it.endsWith("reportUndocumented") }?.startsWith("+")
+ ?: DokkaDefaults.reportUndocumented
+
+ val privateApi = args.find { it.endsWith("includeNonPublic") }?.startsWith("+")
+ ?: DokkaDefaults.includeNonPublic
+
+ val suppress = args.find { it.endsWith("suppress") }?.startsWith("+")
+ ?: DokkaDefaults.suppress
+
+ PackageOptionsImpl(
+ prefix,
+ includeNonPublic = privateApi,
+ reportUndocumented = reportUndocumented,
+ skipDeprecated = !deprecated,
+ suppress = suppress
+ )
}
+
+/**
+ * Accessed with reflection
+ */
+@Suppress("unused")
class DokkaBootstrapImpl : DokkaBootstrap {
- private class DokkaProxyLogger(val consumer: BiConsumer<String, String>) : DokkaLogger {
+ class DokkaProxyLogger(val consumer: BiConsumer<String, String>) : DokkaLogger {
+ override var warningsCount: Int = 0
+ override var errorsCount: Int = 0
+
+ override fun debug(message: String) {
+ consumer.accept("debug", message)
+ }
+
override fun info(message: String) {
consumer.accept("info", message)
}
+ override fun progress(message: String) {
+ consumer.accept("progress", message)
+ }
+
override fun warn(message: String) {
- consumer.accept("warn", message)
+ consumer.accept("warn", message).also { warningsCount++ }
}
override fun error(message: String) {
- consumer.accept("error", message)
+ consumer.accept("error", message).also { errorsCount++ }
}
}
- lateinit var generator: DokkaGenerator
- val gson = Gson()
+ private lateinit var generator: DokkaGenerator
fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) = with(configuration) {
- fun defaultLinks(config: PassConfigurationImpl): List<ExternalDocumentationLinkImpl> {
+ fun defaultLinks(config: DokkaSourceSetImpl): List<ExternalDocumentationLinkImpl> {
val links = mutableListOf<ExternalDocumentationLinkImpl>()
if (!config.noJdkLink)
links += DokkaConfiguration.ExternalDocumentationLink
@@ -57,20 +86,21 @@ class DokkaBootstrapImpl : DokkaBootstrap {
return links
}
- val configurationWithLinks =
- configuration.copy(passesConfigurations =
- passesConfigurations
- .map {
- val links: List<ExternalDocumentationLinkImpl> = it.externalDocumentationLinks + defaultLinks(it)
- it.copy(externalDocumentationLinks = links)
- }
- )
+ val configurationWithLinks = configuration.copy(
+ sourceSets = sourceSets.map {
+ val links: List<ExternalDocumentationLinkImpl> =
+ it.externalDocumentationLinks + defaultLinks(it)
+ it.copy(externalDocumentationLinks = links)
+ }
+ )
generator = DokkaGenerator(configurationWithLinks, logger)
}
- override fun configure(logger: BiConsumer<String, String>, serializedConfigurationJSON: String)
- = configure(DokkaProxyLogger(logger), gson.fromJson(serializedConfigurationJSON, DokkaConfigurationImpl::class.java))
+ override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) = configure(
+ DokkaProxyLogger(logger),
+ DokkaConfigurationImpl(serializedConfigurationJSON)
+ )
override fun generate() = generator.generate()
}