diff options
author | Goooler <wangzongler@gmail.com> | 2022-02-15 17:38:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 12:38:10 +0300 |
commit | 2372302f4bc3b4bf49beb0d477eebdd9ac99a78f (patch) | |
tree | 3a984a8ecdd63da74dfd48a777cc56200ee1d666 /plugins/base/src | |
parent | b0244f69277f492eb87694cf34cc620a265adbcb (diff) | |
download | dokka-2372302f4bc3b4bf49beb0d477eebdd9ac99a78f.tar.gz dokka-2372302f4bc3b4bf49beb0d477eebdd9ac99a78f.tar.bz2 dokka-2372302f4bc3b4bf49beb0d477eebdd9ac99a78f.zip |
Convert interfaces to functional (#2360)
Diffstat (limited to 'plugins/base/src')
10 files changed, 35 insertions, 40 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt index 63db27be..8455320f 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt @@ -1,21 +1,19 @@ package org.jetbrains.dokka.base.resolvers.external -import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.plugability.DokkaContext class DefaultExternalLocationProviderFactory(val context: DokkaContext) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - object : ExternalLocationProviderFactory { - override fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? = - 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 - } + { 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/ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt index 11940abc..8465d41f 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt @@ -5,7 +5,7 @@ import org.jetbrains.dokka.links.DRI /** * Provides the path to the page documenting a [DRI] in an external documentation source */ -interface ExternalLocationProvider { +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) diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt index c7328765..c11a79ba 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt @@ -2,6 +2,6 @@ package org.jetbrains.dokka.base.resolvers.external import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -interface ExternalLocationProviderFactory { +fun interface ExternalLocationProviderFactory { fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? } 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 102d118a..c9ebad81 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt @@ -3,32 +3,29 @@ 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 -import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.plugability.DokkaContext class JavadocExternalLocationProviderFactory(val context: DokkaContext) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - object : ExternalLocationProviderFactory { - override fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? = - 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 - } - } + { 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 + } + } } ) diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt index fb72fc60..26f9028c 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProviderFactory.kt @@ -2,6 +2,6 @@ package org.jetbrains.dokka.base.resolvers.local import org.jetbrains.dokka.pages.RootPageNode -interface LocationProviderFactory { +fun interface LocationProviderFactory { fun getLocationProvider(pageNode: RootPageNode): LocationProvider } diff --git a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt index e1933fb8..03ef3a4e 100644 --- a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt @@ -3,6 +3,6 @@ package org.jetbrains.dokka.base.signatures import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.pages.ContentNode -interface SignatureProvider { +fun interface SignatureProvider { fun signature(documentable: Documentable): List<ContentNode> } diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt index b73b17e0..81822d3e 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka.base.transformers.pages.merger import org.jetbrains.dokka.pages.PageNode -interface PageMergerStrategy { +fun interface PageMergerStrategy { fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> diff --git a/plugins/base/src/main/kotlin/translators/descriptors/ExternalClasslikesTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/ExternalClasslikesTranslator.kt index ec4d1ee9..a5385c46 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/ExternalClasslikesTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/ExternalClasslikesTranslator.kt @@ -7,6 +7,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor /** * Service translating [ClassDescriptor]s of symbols defined outside of documented project to [DClasslike]s. */ -interface ExternalClasslikesTranslator { +fun interface ExternalClasslikesTranslator { fun translateClassDescriptor(descriptor: ClassDescriptor, sourceSet: DokkaSourceSet): DClasslike }
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/translators/descriptors/ExternalDocumentablesProvider.kt b/plugins/base/src/main/kotlin/translators/descriptors/ExternalDocumentablesProvider.kt index c1dbfc28..e6d499f4 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/ExternalDocumentablesProvider.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/ExternalDocumentablesProvider.kt @@ -11,7 +11,7 @@ import org.jetbrains.dokka.model.DClasslike * in the project itself but are somehow related to the symbols defined in the documented project (e.g. are supertypes * of classes defined in project). */ -interface ExternalDocumentablesProvider { +fun interface ExternalDocumentablesProvider { /** * Returns [DClasslike] matching provided [DRI] in specified source set. diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt index 13d17f52..f93f7d6d 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -30,7 +30,7 @@ import org.jsoup.nodes.Node import org.jsoup.nodes.TextNode import java.util.* -interface JavaDocumentationParser { +fun interface JavaDocumentationParser { fun parseDocumentation(element: PsiNamedElement): DocumentationNode } |