diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-08-24 15:06:36 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-25 13:12:48 +0200 |
commit | cd3f48ec64e60221bd63720fa24cff8fd7afe6c7 (patch) | |
tree | e01483148b5d7ef5afa7c7090d82a8bdba7d7db0 /plugins/base/src/main/kotlin/resolvers | |
parent | 293d8788b5188cb29a8c792e7d54377b57963f3b (diff) | |
download | dokka-cd3f48ec64e60221bd63720fa24cff8fd7afe6c7.tar.gz dokka-cd3f48ec64e60221bd63720fa24cff8fd7afe6c7.tar.bz2 dokka-cd3f48ec64e60221bd63720fa24cff8fd7afe6c7.zip |
Fix external links to Android and Androix documentations
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers')
3 files changed, 43 insertions, 16 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt new file mode 100644 index 00000000..0d4d8766 --- /dev/null +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt @@ -0,0 +1,14 @@ +package org.jetbrains.dokka.base.resolvers.external.javadoc + +import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation +import org.jetbrains.dokka.links.Callable +import org.jetbrains.dokka.plugability.DokkaContext + +open class AndroidExternalLocationProvider( + externalDocumentation: ExternalDocumentation, + dokkaContext: DokkaContext +) : JavadocExternalLocationProvider(externalDocumentation, "", "", dokkaContext) { + + override fun anchorPart(callable: Callable) = callable.name.toLowerCase() + +} diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt index 60aa540a..d4f44a94 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt @@ -2,11 +2,12 @@ package org.jetbrains.dokka.base.resolvers.external.javadoc import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation +import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.htmlEscape -class JavadocExternalLocationProvider( +open class JavadocExternalLocationProvider( externalDocumentation: ExternalDocumentation, val brackets: String, val separator: String, @@ -21,13 +22,16 @@ class JavadocExternalLocationProvider( if (dri.classNames == null) { return "$docURL$packageLink/package-summary$extension".htmlEscape() } - val classLink = if (packageLink == null) "${dri.classNames}$extension" else "$packageLink/${dri.classNames}$extension" + val classLink = + if (packageLink == null) "${dri.classNames}$extension" else "$packageLink/${dri.classNames}$extension" val callableChecked = dri.callable ?: return "$docURL$classLink".htmlEscape() - return ("$docURL$classLink#" + - callableChecked.name + - "${brackets.first()}" + - callableChecked.params.joinToString(separator) + - "${brackets.last()}").htmlEscape() + return ("$docURL$classLink#" + anchorPart(callableChecked)).htmlEscape() } + + protected open fun anchorPart(callable: Callable) = callable.name + + "${brackets.first()}" + + callable.params.joinToString(separator) + + "${brackets.last()}" + } diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt index 27e0cd02..102d118a 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt @@ -1,5 +1,8 @@ package org.jetbrains.dokka.base.resolvers.external.javadoc +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.androidSdk +import org.jetbrains.dokka.androidX import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProvider import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFactory import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFactoryWithCache @@ -11,15 +14,21 @@ class JavadocExternalLocationProviderFactory(val context: DokkaContext) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( object : ExternalLocationProviderFactory { override fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? = - when (doc.packageList.linkFormat) { - RecognizedLinkFormat.Javadoc1 -> - JavadocExternalLocationProvider(doc, "()", ", ", context) // Covers JDK 1 - 7 - RecognizedLinkFormat.Javadoc8 -> - JavadocExternalLocationProvider(doc, "--", "-", context) // Covers JDK 8 - 9 - RecognizedLinkFormat.Javadoc10, - RecognizedLinkFormat.DokkaJavadoc -> - JavadocExternalLocationProvider(doc, "()", ",", context) // Covers JDK 10 - else -> null + when (doc.packageList.url) { + DokkaConfiguration.ExternalDocumentationLink.androidX().packageListUrl, + DokkaConfiguration.ExternalDocumentationLink.androidSdk().packageListUrl -> + AndroidExternalLocationProvider(doc, context) + else -> + when (doc.packageList.linkFormat) { + RecognizedLinkFormat.Javadoc1 -> + JavadocExternalLocationProvider(doc, "()", ", ", context) // Covers JDK 1 - 7 + RecognizedLinkFormat.Javadoc8 -> + JavadocExternalLocationProvider(doc, "--", "-", context) // Covers JDK 8 - 9 + RecognizedLinkFormat.Javadoc10, + RecognizedLinkFormat.DokkaJavadoc -> + JavadocExternalLocationProvider(doc, "()", ",", context) // Covers JDK 10 + else -> null + } } } ) |