diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/configuration.kt | 29 | ||||
-rw-r--r-- | core/src/main/kotlin/defaultExternalLinks.kt | 31 |
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") + ) +} |