diff options
author | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2022-01-12 15:04:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-12 17:04:59 +0300 |
commit | 6b729257b89ff5a19a52045efa386349feec0bc6 (patch) | |
tree | 790ca1fc300466496dc18e045997d4818b7a50e1 /runners/cli/src/main | |
parent | b30db0aeafd5663dce3d3020f3dde6599ec368f3 (diff) | |
download | dokka-6b729257b89ff5a19a52045efa386349feec0bc6.tar.gz dokka-6b729257b89ff5a19a52045efa386349feec0bc6.tar.bz2 dokka-6b729257b89ff5a19a52045efa386349feec0bc6.zip |
Add global settings to JSON dokka cli input (#2292)
* Add global settings to JSON dokka cli input
* Apply requested changes
* Move initialization of global arguments to extension function in core module
Diffstat (limited to 'runners/cli/src/main')
-rw-r--r-- | runners/cli/src/main/kotlin/cli/main.kt | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 739539a9..1dc32a45 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -2,10 +2,7 @@ package org.jetbrains.dokka import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import org.jetbrains.dokka.utilities.DokkaConsoleLogger -import org.jetbrains.dokka.utilities.DokkaLogger -import org.jetbrains.dokka.utilities.LoggingLevel -import org.jetbrains.dokka.utilities.cast +import org.jetbrains.dokka.utilities.* import java.io.* import java.net.MalformedURLException import java.net.URL @@ -80,6 +77,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration { private val _includes by parser.option( ArgTypeFile, + fullName = "includes", description = "Markdown files that would be displayed in multi-module page separated by the semicolon `;`)" ).delimiter(";") @@ -406,14 +404,23 @@ fun parseLinks(links: List<String>): List<ExternalDocumentationLink> { } } +fun initializeConfiguration(globalArguments: GlobalArguments): DokkaConfiguration = if (globalArguments.json != null) { + val jsonContent = Paths.get(checkNotNull(globalArguments.json)).toFile().readText() + val globals = GlobalDokkaConfiguration(jsonContent) + val dokkaConfigurationImpl = DokkaConfigurationImpl(jsonContent) + + dokkaConfigurationImpl.apply(globals).apply { + sourceSets.forEach { + it.externalDocumentationLinks.cast<MutableSet<ExternalDocumentationLink>>().addAll(defaultLinks(it)) + } + } + } else { + globalArguments + } + fun main(args: Array<String>) { val globalArguments = GlobalArguments(args) - val configuration = if (globalArguments.json != null) - DokkaConfigurationImpl( - Paths.get(checkNotNull(globalArguments.json)).toFile().readText() - ) - else - globalArguments + val configuration = initializeConfiguration(globalArguments) DokkaGenerator(configuration, globalArguments.logger).generate() } |