aboutsummaryrefslogtreecommitdiff
path: root/runners/cli/src/main/kotlin
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-31 08:26:57 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-14 17:51:11 +0200
commit5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8 (patch)
tree76d20e3d74d471d87eaa0c060d6787861d8c4919 /runners/cli/src/main/kotlin
parentaa21ab173d60bb69e50e7fc321e8b94c2815b6e8 (diff)
downloaddokka-5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8.tar.gz
dokka-5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8.tar.bz2
dokka-5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8.zip
Replace ExternalDocumentationLink.Builder with factory functions
Diffstat (limited to 'runners/cli/src/main/kotlin')
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt27
1 files changed, 9 insertions, 18 deletions
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
index 43c46d92..4b0bd04e 100644
--- a/runners/cli/src/main/kotlin/cli/main.kt
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -299,26 +299,17 @@ object ArgTypeHelpSourceSet : ArgType<Any>(false) {
get() = ""
}
+@OptIn(ExperimentalStdlibApi::class)
fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList<ExternalDocumentationLink> =
- mutableListOf<ExternalDocumentationLink>().apply {
+ buildList<ExternalDocumentationLink> {
if (!config.noJdkLink) {
- // TODO NOW: Duplication
- val javadocLink =
- if (config.jdkVersion < 11) "https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/"
- else "https://docs.oracle.com/en/java/javase/${config.jdkVersion}/docs/api/java.base/"
- val packageListLink =
- if (config.jdkVersion < 11) "${javadocLink}/package-list"
- else "https://docs.oracle.com/en/java/javase/${config.jdkVersion}/docs/api/element-list"
- this += ExternalDocumentationLink
- .Builder(javadocLink, packageListLink)
- .build()
+ add(ExternalDocumentationLink.jdk(config.jdkVersion))
}
- if (!config.noStdlibLink)
- this += ExternalDocumentationLink
- .Builder("https://kotlinlang.org/api/latest/jvm/stdlib/")
- .build()
- }
+ if (!config.noStdlibLink) {
+ add(ExternalDocumentationLink.kotlinStdlib())
+ }
+ }.toMutableList()
fun parseLinks(links: List<String>): List<ExternalDocumentationLink> {
@@ -327,7 +318,7 @@ fun parseLinks(links: List<String>): List<ExternalDocumentationLink> {
.filter { it.isNotEmpty() }
.partition { it.size == 1 }
- return parsedLinks.map { (root) -> ExternalDocumentationLink.Builder(root).build() } +
+ return parsedLinks.map { (root) -> ExternalDocumentationLink(root) } +
parsedOfflineLinks.map { (root, packageList) ->
val rootUrl = URL(root)
val packageListUrl =
@@ -336,7 +327,7 @@ fun parseLinks(links: List<String>): List<ExternalDocumentationLink> {
} catch (ex: MalformedURLException) {
File(packageList).toURI().toURL()
}
- ExternalDocumentationLink.Builder(rootUrl, packageListUrl).build()
+ ExternalDocumentationLink(rootUrl, packageListUrl)
}
}