From 5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Fri, 31 Jul 2020 08:26:57 +0200 Subject: Replace ExternalDocumentationLink.Builder with factory functions --- runners/cli/src/main/kotlin/cli/main.kt | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'runners/cli/src/main/kotlin') 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(false) { get() = "" } +@OptIn(ExperimentalStdlibApi::class) fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList = - mutableListOf().apply { + buildList { 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): List { @@ -327,7 +318,7 @@ fun parseLinks(links: List): List { .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): List { } catch (ex: MalformedURLException) { File(packageList).toURI().toURL() } - ExternalDocumentationLink.Builder(rootUrl, packageListUrl).build() + ExternalDocumentationLink(rootUrl, packageListUrl) } } -- cgit