aboutsummaryrefslogtreecommitdiff
path: root/runners/cli/src/main/kotlin/org/jetbrains/dokka
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-08-31 20:16:01 +0200
committerGitHub <noreply@github.com>2023-08-31 20:16:01 +0200
commit02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch)
tree66f6d6f089a93b863bf1144666491eca6729ad05 /runners/cli/src/main/kotlin/org/jetbrains/dokka
parent6a181a7a2b03ec263788d137610e86937a57d434 (diff)
downloaddokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip
Enable explicit API mode (#3139)
Diffstat (limited to 'runners/cli/src/main/kotlin/org/jetbrains/dokka')
-rw-r--r--runners/cli/src/main/kotlin/org/jetbrains/dokka/CliArgumentTypes.kt19
-rw-r--r--runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt38
-rw-r--r--runners/cli/src/main/kotlin/org/jetbrains/dokka/LinkMapper.kt4
-rw-r--r--runners/cli/src/main/kotlin/org/jetbrains/dokka/main.kt4
4 files changed, 34 insertions, 31 deletions
diff --git a/runners/cli/src/main/kotlin/org/jetbrains/dokka/CliArgumentTypes.kt b/runners/cli/src/main/kotlin/org/jetbrains/dokka/CliArgumentTypes.kt
index b889bdc6..1c6b0ba4 100644
--- a/runners/cli/src/main/kotlin/org/jetbrains/dokka/CliArgumentTypes.kt
+++ b/runners/cli/src/main/kotlin/org/jetbrains/dokka/CliArgumentTypes.kt
@@ -11,20 +11,23 @@ import java.io.File
import java.nio.file.Paths
-object ArgTypeFile : ArgType<File>(true) {
+public object ArgTypeFile : ArgType<File>(true) {
override fun convert(value: kotlin.String, name: kotlin.String): File = Paths.get(value).toRealPath().toFile()
override val description: kotlin.String
get() = "{ String that represents a directory / file path }"
}
-object ArgTypePlatform : ArgType<Platform>(true) {
+public object ArgTypePlatform : ArgType<Platform>(true) {
override fun convert(value: kotlin.String, name: kotlin.String): Platform = Platform.fromString(value)
override val description: kotlin.String
get() = "{ String that represents a Kotlin platform. Possible values: jvm/js/native/common/android }"
}
-object ArgTypeVisibility : ArgType<DokkaConfiguration.Visibility>(true) {
- override fun convert(value: kotlin.String, name: kotlin.String) = DokkaConfiguration.Visibility.fromString(value)
+public object ArgTypeVisibility : ArgType<DokkaConfiguration.Visibility>(true) {
+ override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.Visibility {
+ return DokkaConfiguration.Visibility.fromString(value)
+ }
+
override val description: kotlin.String
get() = "{ String that represents a visibility modifier. Possible values: ${getPossibleVisibilityValues()}"
@@ -32,7 +35,7 @@ object ArgTypeVisibility : ArgType<DokkaConfiguration.Visibility>(true) {
DokkaConfiguration.Visibility.values().joinToString(separator = ", ")
}
-object ArgTypePlugin : ArgType<DokkaConfiguration.PluginConfiguration>(true) {
+public object ArgTypePlugin : ArgType<DokkaConfiguration.PluginConfiguration>(true) {
override fun convert(
value: kotlin.String,
name: kotlin.String
@@ -52,7 +55,7 @@ object ArgTypePlugin : ArgType<DokkaConfiguration.PluginConfiguration>(true) {
"Quotation marks (`\"`) inside json must be escaped. }"
}
-object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefinition>(true) {
+public object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefinition>(true) {
override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.SourceLinkDefinition {
return if (value.isNotEmpty() && value.contains("="))
SourceLinkDefinitionImpl.parseSourceLinkDefinition(value)
@@ -68,7 +71,7 @@ object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefini
get() = "{ String that represent source links. Format: {srcPath}={remotePath#lineSuffix} }"
}
-data class ArgTypeArgument(val moduleName: CLIEntity<kotlin.String>) :
+public data class ArgTypeArgument(val moduleName: CLIEntity<kotlin.String>) :
ArgType<DokkaConfiguration.DokkaSourceSet>(true) {
override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet =
(if (moduleName.valueOrigin != ArgParser.ValueOrigin.UNSET && moduleName.valueOrigin != ArgParser.ValueOrigin.UNDEFINED) {
@@ -84,7 +87,7 @@ data class ArgTypeArgument(val moduleName: CLIEntity<kotlin.String>) :
}
// Workaround for printing nested parsers help
-data class ArgTypeHelpSourceSet(val moduleName: CLIEntity<kotlin.String>) : ArgType<Any>(false) {
+public data class ArgTypeHelpSourceSet(val moduleName: CLIEntity<kotlin.String>) : ArgType<Any>(false) {
override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also {
parseSourceSet(moduleName.value, arrayOf("-h"))
}
diff --git a/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt b/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt
index f8e04053..5c95f63f 100644
--- a/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt
+++ b/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt
@@ -11,11 +11,11 @@ import org.jetbrains.dokka.utilities.LoggingLevel
import org.jetbrains.dokka.utilities.cast
import java.io.File
-class GlobalArguments(args: Array<String>) : DokkaConfiguration {
+public class GlobalArguments(args: Array<String>) : DokkaConfiguration {
- val parser = ArgParser("dokka-cli", prefixStyle = ArgParser.OptionPrefixStyle.JVM)
+ public val parser: ArgParser = ArgParser("dokka-cli", prefixStyle = ArgParser.OptionPrefixStyle.JVM)
- val json: String? by parser.argument(ArgType.String, description = "JSON configuration file path").optional()
+ public val json: String? by parser.argument(ArgType.String, description = "JSON configuration file path").optional()
private val _moduleName = parser.option(
ArgType.String,
@@ -25,50 +25,50 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
override val moduleName: String by _moduleName
- override val moduleVersion by parser.option(
+ override val moduleVersion: String? by parser.option(
ArgType.String,
description = "Documented version",
fullName = "moduleVersion"
)
- override val outputDir by parser.option(ArgTypeFile, description = "Output directory path, ./dokka by default")
+ override val outputDir: File by parser.option(ArgTypeFile, description = "Output directory path, ./dokka by default")
.default(DokkaDefaults.outputDir)
- override val cacheRoot = null
+ override val cacheRoot: File? = null
- override val sourceSets by parser.option(
+ override val sourceSets: List<DokkaConfiguration.DokkaSourceSet> by parser.option(
ArgTypeArgument(_moduleName),
description = "Configuration for a Dokka source set. Contains nested configuration.",
fullName = "sourceSet"
).multiple()
- override val pluginsConfiguration by parser.option(
+ override val pluginsConfiguration: List<DokkaConfiguration.PluginConfiguration> by parser.option(
ArgTypePlugin,
description = "Configuration for Dokka plugins. Accepts multiple values separated by `^^`."
).delimiter("^^")
- override val pluginsClasspath by parser.option(
+ override val pluginsClasspath: List<File> by parser.option(
ArgTypeFile,
fullName = "pluginsClasspath",
description = "List of jars with Dokka plugins and their dependencies. Accepts multiple paths separated by semicolons"
).delimiter(";")
- override val offlineMode by parser.option(
+ override val offlineMode: Boolean by parser.option(
ArgType.Boolean,
description = "Whether to resolve remote files/links over network"
).default(DokkaDefaults.offlineMode)
- override val failOnWarning by parser.option(
+ override val failOnWarning: Boolean by parser.option(
ArgType.Boolean,
description = "Whether to fail documentation generation if Dokka has emitted a warning or an error"
).default(DokkaDefaults.failOnWarning)
- override val delayTemplateSubstitution by parser.option(
+ override val delayTemplateSubstitution: Boolean by parser.option(
ArgType.Boolean,
description = "Delay substitution of some elements. Used in incremental builds of multimodule projects"
).default(DokkaDefaults.delayTemplateSubstitution)
- val noSuppressObviousFunctions: Boolean by parser.option(
+ public val noSuppressObviousFunctions: Boolean by parser.option(
ArgType.Boolean,
description = "Whether to suppress obvious functions such as inherited from `kotlin.Any` and `java.lang.Object`"
).default(!DokkaDefaults.suppressObviousFunctions)
@@ -91,31 +91,31 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
override val finalizeCoroutines: Boolean = true
- val globalPackageOptions by parser.option(
+ public val globalPackageOptions: List<String> by parser.option(
ArgType.String,
description = "Global list of package configurations in format " +
"\"matchingRegexp,-deprecated,-privateApi,+warnUndocumented,+suppress;...\". " +
"Accepts multiple values separated by semicolons. "
).delimiter(";")
- val globalLinks by parser.option(
+ public val globalLinks: List<String> by parser.option(
ArgType.String,
description = "Global external documentation links in format {url}^{packageListUrl}. " +
"Accepts multiple values separated by `^^`"
).delimiter("^^")
- val globalSrcLink by parser.option(
+ public val globalSrcLink: List<String> by parser.option(
ArgType.String,
description = "Global mapping between a source directory and a Web service for browsing the code. " +
"Accepts multiple paths separated by semicolons"
).delimiter(";")
- val helpSourceSet by parser.option(
+ public val helpSourceSet: Any? by parser.option(
ArgTypeHelpSourceSet(_moduleName),
description = "Prints help for nested -sourceSet configuration"
)
- val loggingLevel by parser.option(
+ public val loggingLevel: LoggingLevel by parser.option(
ArgType.Choice(toVariant = {
when (it.toUpperCase().trim()) {
"DEBUG", "" -> LoggingLevel.DEBUG
@@ -134,7 +134,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
override val modules: List<DokkaConfiguration.DokkaModuleDescription> = emptyList()
- val logger: DokkaLogger by lazy {
+ public val logger: DokkaLogger by lazy {
DokkaConsoleLogger(loggingLevel)
}
diff --git a/runners/cli/src/main/kotlin/org/jetbrains/dokka/LinkMapper.kt b/runners/cli/src/main/kotlin/org/jetbrains/dokka/LinkMapper.kt
index 7d22f6d9..dbfa8db1 100644
--- a/runners/cli/src/main/kotlin/org/jetbrains/dokka/LinkMapper.kt
+++ b/runners/cli/src/main/kotlin/org/jetbrains/dokka/LinkMapper.kt
@@ -9,7 +9,7 @@ import java.net.MalformedURLException
import java.net.URL
@OptIn(ExperimentalStdlibApi::class) // for buildList
-fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList<DokkaConfiguration.ExternalDocumentationLink> =
+public fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList<DokkaConfiguration.ExternalDocumentationLink> =
buildList<DokkaConfiguration.ExternalDocumentationLink> {
if (!config.noJdkLink) {
add(DokkaConfiguration.ExternalDocumentationLink.jdk(config.jdkVersion))
@@ -21,7 +21,7 @@ fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList<DokkaCo
}.toMutableList()
-fun parseLinks(links: List<String>): List<DokkaConfiguration.ExternalDocumentationLink> {
+public fun parseLinks(links: List<String>): List<DokkaConfiguration.ExternalDocumentationLink> {
val (parsedLinks, parsedOfflineLinks) = links
.map { it.split("^").map { it.trim() }.filter { it.isNotBlank() } }
.filter { it.isNotEmpty() }
diff --git a/runners/cli/src/main/kotlin/org/jetbrains/dokka/main.kt b/runners/cli/src/main/kotlin/org/jetbrains/dokka/main.kt
index 4a2a27ca..e1949a93 100644
--- a/runners/cli/src/main/kotlin/org/jetbrains/dokka/main.kt
+++ b/runners/cli/src/main/kotlin/org/jetbrains/dokka/main.kt
@@ -8,13 +8,13 @@ import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
import org.jetbrains.dokka.utilities.*
import java.nio.file.Paths
-fun main(args: Array<String>) {
+public fun main(args: Array<String>) {
val globalArguments = GlobalArguments(args)
val configuration = initializeConfiguration(globalArguments)
DokkaGenerator(configuration, globalArguments.logger).generate()
}
-fun initializeConfiguration(globalArguments: GlobalArguments): DokkaConfiguration {
+public fun initializeConfiguration(globalArguments: GlobalArguments): DokkaConfiguration {
return if (globalArguments.json != null) {
val jsonContent = Paths.get(checkNotNull(globalArguments.json)).toFile().readText()
val globals = GlobalDokkaConfiguration(jsonContent)