diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-08-31 20:16:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-31 20:16:01 +0200 |
commit | 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch) | |
tree | 66f6d6f089a93b863bf1144666491eca6729ad05 /plugins/base/src/main/kotlin/resolvers/external | |
parent | 6a181a7a2b03ec263788d137610e86937a57d434 (diff) | |
download | dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2 dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip |
Enable explicit API mode (#3139)
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers/external')
9 files changed, 70 insertions, 59 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt index 1e4cc8dd..32825303 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt @@ -9,12 +9,12 @@ import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.plugability.DokkaContext -open class DefaultExternalLocationProvider( - val externalDocumentation: ExternalDocumentation, - val extension: String, - val dokkaContext: DokkaContext +public open class DefaultExternalLocationProvider( + public val externalDocumentation: ExternalDocumentation, + public val extension: String, + public val dokkaContext: DokkaContext ) : ExternalLocationProvider { - val docURL = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" + public val docURL: String = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" override fun resolve(dri: DRI): String? { externalDocumentation.packageList.locations[dri.toString()]?.let { path -> return "$docURL$path" } diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt index 62135446..09ddca01 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt @@ -7,17 +7,22 @@ package org.jetbrains.dokka.base.resolvers.external import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.plugability.DokkaContext -class DefaultExternalLocationProviderFactory(val context: DokkaContext) : - ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - { doc -> - when (doc.packageList.linkFormat) { - RecognizedLinkFormat.KotlinWebsite, - RecognizedLinkFormat.KotlinWebsiteHtml, - RecognizedLinkFormat.DokkaOldHtml -> Dokka010ExternalLocationProvider(doc, ".html", context) - RecognizedLinkFormat.DokkaHtml -> DefaultExternalLocationProvider(doc, ".html", context) - RecognizedLinkFormat.DokkaGFM, - RecognizedLinkFormat.DokkaJekyll -> DefaultExternalLocationProvider(doc, ".md", context) - else -> null - } +public class DefaultExternalLocationProviderFactory( + public val context: DokkaContext, +) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( + { doc -> + when (doc.packageList.linkFormat) { + RecognizedLinkFormat.KotlinWebsite, + RecognizedLinkFormat.KotlinWebsiteHtml, + RecognizedLinkFormat.DokkaOldHtml, + -> Dokka010ExternalLocationProvider(doc, ".html", context) + + RecognizedLinkFormat.DokkaHtml -> DefaultExternalLocationProvider(doc, ".html", context) + RecognizedLinkFormat.DokkaGFM, + RecognizedLinkFormat.DokkaJekyll, + -> DefaultExternalLocationProvider(doc, ".md", context) + + else -> null } - ) + } +) diff --git a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt index 0e94ceb4..f887c9bc 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt @@ -10,12 +10,12 @@ import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.plugability.DokkaContext -open class Dokka010ExternalLocationProvider( - val externalDocumentation: ExternalDocumentation, - val extension: String, - val dokkaContext: DokkaContext +public open class Dokka010ExternalLocationProvider( + public val externalDocumentation: ExternalDocumentation, + public val extension: String, + public val dokkaContext: DokkaContext ) : ExternalLocationProvider { - val docURL = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" + public val docURL: String = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" override fun resolve(dri: DRI): String? { diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt index 599dfc87..238b6342 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt @@ -9,10 +9,10 @@ import org.jetbrains.dokka.links.DRI /** * Provides the path to the page documenting a [DRI] in an external documentation source */ -fun interface ExternalLocationProvider { +public fun interface ExternalLocationProvider { /** * @return Path to the page containing the [dri] or null if the path cannot be created * (eg. when the package-list does not contain [dri]'s package) */ - fun resolve(dri: DRI): String? + public fun resolve(dri: DRI): String? } diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt index 517024e4..952f4d51 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.base.resolvers.external import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -fun interface ExternalLocationProviderFactory { - fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? +public fun interface ExternalLocationProviderFactory { + public fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? } diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt index 12b1b7eb..0b56e174 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt @@ -7,8 +7,9 @@ package org.jetbrains.dokka.base.resolvers.external import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import java.util.concurrent.ConcurrentHashMap -class ExternalLocationProviderFactoryWithCache(val ext: ExternalLocationProviderFactory) : - ExternalLocationProviderFactory { +public class ExternalLocationProviderFactoryWithCache( + public val ext: ExternalLocationProviderFactory +) : ExternalLocationProviderFactory { private val locationProviders = ConcurrentHashMap<ExternalDocumentation, CacheWrapper>() diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt index e90adf6f..8c18be0c 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt @@ -8,11 +8,11 @@ import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.plugability.DokkaContext -open class AndroidExternalLocationProvider( +public open class AndroidExternalLocationProvider( externalDocumentation: ExternalDocumentation, dokkaContext: DokkaContext ) : JavadocExternalLocationProvider(externalDocumentation, "", "", dokkaContext) { - override fun anchorPart(callable: Callable) = callable.name.toLowerCase() + override fun anchorPart(callable: Callable): String = 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 d7351556..65ee0e02 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt @@ -13,10 +13,10 @@ import org.jetbrains.dokka.links.EnumEntryDRIExtra import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.htmlEscape -open class JavadocExternalLocationProvider( +public open class JavadocExternalLocationProvider( externalDocumentation: ExternalDocumentation, - val brackets: String, - val separator: String, + public val brackets: String, + public val separator: String, dokkaContext: DokkaContext ) : DefaultExternalLocationProvider(externalDocumentation, ".html", dokkaContext) { @@ -53,9 +53,10 @@ open class JavadocExternalLocationProvider( return ("$docWithModule$classLink#" + anchorPart(callableChecked)).htmlEscape() } - protected open fun anchorPart(callable: Callable) = callable.name + - "${brackets.first()}" + - callable.params.joinToString(separator) + - "${brackets.last()}" - + protected open fun anchorPart(callable: Callable): String { + return 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 6b94a75b..dc184e49 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt @@ -12,24 +12,28 @@ import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFacto import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.plugability.DokkaContext -class JavadocExternalLocationProviderFactory(val context: DokkaContext) : - ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - { doc -> - 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 - } - } +public class JavadocExternalLocationProviderFactory( + public val context: DokkaContext, +) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( + { doc -> + 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 + } } - ) + } +) |