aboutsummaryrefslogtreecommitdiff
path: root/core
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 /core
parentaa21ab173d60bb69e50e7fc321e8b94c2815b6e8 (diff)
downloaddokka-5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8.tar.gz
dokka-5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8.tar.bz2
dokka-5e50c7b9d5bc9da46365f43bd6f9346f91ad36f8.zip
Replace ExternalDocumentationLink.Builder with factory functions
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/configuration.kt29
-rw-r--r--core/src/main/kotlin/defaultExternalLinks.kt31
2 files changed, 41 insertions, 19 deletions
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt
index 35c0f02e..fbe7ccfc 100644
--- a/core/src/main/kotlin/configuration.kt
+++ b/core/src/main/kotlin/configuration.kt
@@ -129,35 +129,26 @@ interface DokkaConfiguration : Serializable {
interface ExternalDocumentationLink : Serializable {
val url: URL
val packageListUrl: URL
-
- open class Builder(
- open var url: URL? = null,
- open var packageListUrl: URL? = null
- ) {
-
- constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) })
-
- fun build(): ExternalDocumentationLinkImpl =
- if (packageListUrl != null && url != null)
- ExternalDocumentationLinkImpl(url!!, packageListUrl!!)
- else if (url != null)
- ExternalDocumentationLinkImpl(url!!, URL(url!!, "package-list"))
- else
- throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link")
- }
+ companion object
}
}
fun ExternalDocumentationLink(
url: URL? = null,
packageListUrl: URL? = null
-): ExternalDocumentationLinkImpl =
- DokkaConfiguration.ExternalDocumentationLink.Builder(url = url, packageListUrl = packageListUrl).build()
+): ExternalDocumentationLinkImpl {
+ return if (packageListUrl != null && url != null)
+ ExternalDocumentationLinkImpl(url, packageListUrl)
+ else if (url != null)
+ ExternalDocumentationLinkImpl(url, URL(url, "package-list"))
+ else
+ throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link")
+}
fun ExternalDocumentationLink(
url: String, packageListUrl: String? = null
): ExternalDocumentationLinkImpl =
- DokkaConfiguration.ExternalDocumentationLink.Builder(root = url, packageList = packageListUrl).build()
+ ExternalDocumentationLink(url.let(::URL), packageListUrl?.let(::URL))
diff --git a/core/src/main/kotlin/defaultExternalLinks.kt b/core/src/main/kotlin/defaultExternalLinks.kt
new file mode 100644
index 00000000..d8c95076
--- /dev/null
+++ b/core/src/main/kotlin/defaultExternalLinks.kt
@@ -0,0 +1,31 @@
+package org.jetbrains.dokka
+
+import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
+import java.net.URL
+
+
+fun ExternalDocumentationLink.Companion.jdk(jdkVersion: Int): ExternalDocumentationLinkImpl {
+ return ExternalDocumentationLink(
+ url =
+ if (jdkVersion < 11) "https://docs.oracle.com/javase/${jdkVersion}/docs/api/"
+ else "https://docs.oracle.com/en/java/javase/${jdkVersion}/docs/api/java.base/",
+ packageListUrl =
+ if (jdkVersion < 11) "https://docs.oracle.com/javase/${jdkVersion}/docs/api/package-list"
+ else "https://docs.oracle.com/en/java/javase/${jdkVersion}/docs/api/element-list"
+ )
+}
+
+fun ExternalDocumentationLink.Companion.kotlinStdlib(): ExternalDocumentationLinkImpl {
+ return ExternalDocumentationLink("https://kotlinlang.org/api/latest/jvm/stdlib/")
+}
+
+fun ExternalDocumentationLink.Companion.androidSdk(): ExternalDocumentationLinkImpl {
+ return ExternalDocumentationLink("https://developer.android.com/reference/")
+}
+
+fun ExternalDocumentationLink.Companion.androidX(): ExternalDocumentationLinkImpl {
+ return ExternalDocumentationLink(
+ url = URL("https://developer.android.com/reference/kotlin/"),
+ packageListUrl = URL("https://developer.android.com/reference/androidx/package-list")
+ )
+}