diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2020-10-18 23:04:26 +0200 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-11-09 14:56:24 +0100 |
commit | be80016c77e9b98a75d8e832dd5723737f0e1d72 (patch) | |
tree | d4a1124e9278fcfb3a1c1b00cf743d8553ded011 /plugins/javadoc | |
parent | 1aba0ec4973d7915caa93f1e9b3146ad82111903 (diff) | |
download | dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.tar.gz dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.tar.bz2 dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.zip |
Cleaning querying from plugins where possible
Diffstat (limited to 'plugins/javadoc')
5 files changed, 25 insertions, 43 deletions
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt index 8cfd4911..ff9f2e32 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt @@ -1,19 +1,12 @@ package org.jetbrains.dokka.javadoc -import org.jetbrains.dokka.base.signatures.SignatureProvider -import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator -import org.jetbrains.dokka.utilities.DokkaLogger class JavadocDocumentableToPageTranslator( - private val context: DokkaContext, - private val signatureProvider: SignatureProvider, - private val logger: DokkaLogger + private val context: DokkaContext ) : DocumentableToPageTranslator { - override fun invoke(module: DModule): RootPageNode = - JavadocPageCreator(context, signatureProvider, logger).pageForModule(module) + override fun invoke(module: DModule): RootPageNode = JavadocPageCreator(context).pageForModule(module) }
\ No newline at end of file diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt index 0e6bdc33..4d0a62c3 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka.javadoc import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter import org.jetbrains.dokka.base.translators.documentables.briefFromContentNodes @@ -14,14 +15,12 @@ import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.utilities.DokkaLogger +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle import kotlin.reflect.KClass -open class JavadocPageCreator( - context: DokkaContext, - private val signatureProvider: SignatureProvider, - val logger: DokkaLogger -) { +open class JavadocPageCreator(context: DokkaContext) { + private val signatureProvider: SignatureProvider = context.plugin<DokkaBase>().querySingle { signatureProvider } private val documentationVersion = context.configuration.moduleVersion fun pageForModule(m: DModule): JavadocModulePageNode = diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt index 560083e4..d23aaa4e 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt @@ -13,7 +13,6 @@ import org.jetbrains.dokka.javadoc.transformers.documentables.JavadocDocumentabl import org.jetbrains.dokka.javadoc.validity.MultiplatformConfiguredChecker import org.jetbrains.dokka.kotlinAsJava.KotlinAsJavaPlugin import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.transformers.pages.PageTransformer class JavadocPlugin : DokkaPlugin() { @@ -24,46 +23,28 @@ class JavadocPlugin : DokkaPlugin() { val javadocPreprocessors by extensionPoint<PageTransformer>() val dokkaJavadocPlugin by extending { - (CoreExtensions.renderer - providing { ctx -> KorteJavadocRenderer(dokkaBasePlugin.querySingle { outputWriter }, ctx, "views") } - override dokkaBasePlugin.htmlRenderer) + CoreExtensions.renderer providing { ctx -> KorteJavadocRenderer(ctx, "views") } override dokkaBasePlugin.htmlRenderer } val javadocMultiplatformCheck by extending { - CoreExtensions.preGenerationCheck providing { context -> - MultiplatformConfiguredChecker(context) - } + CoreExtensions.preGenerationCheck providing ::MultiplatformConfiguredChecker } val pageTranslator by extending { - CoreExtensions.documentableToPageTranslator providing { context -> - JavadocDocumentableToPageTranslator( - context, - dokkaBasePlugin.querySingle { signatureProvider }, - context.logger - ) - } override kotinAsJavaPlugin.kotlinAsJavaDocumentableToPageTranslator + CoreExtensions.documentableToPageTranslator providing ::JavadocDocumentableToPageTranslator override + kotinAsJavaPlugin.kotlinAsJavaDocumentableToPageTranslator } val documentableSourceSetFilter by extending { - CoreExtensions.preMergeDocumentableTransformer providing { context -> JavadocDocumentableJVMSourceSetFilter(context) } + CoreExtensions.preMergeDocumentableTransformer providing ::JavadocDocumentableJVMSourceSetFilter } val javadocLocationProviderFactory by extending { - dokkaBasePlugin.locationProviderFactory providing { context -> - JavadocLocationProviderFactory(context) - } override dokkaBasePlugin.locationProvider + dokkaBasePlugin.locationProviderFactory providing ::JavadocLocationProviderFactory override dokkaBasePlugin.locationProvider } val javadocSignatureProvider by extending { - val dokkaBasePlugin = plugin<DokkaBase>() - dokkaBasePlugin.signatureProvider providing { ctx -> - JavadocSignatureProvider( - ctx.single( - dokkaBasePlugin.commentsToContentConverter - ), ctx.logger - ) - } override kotinAsJavaPlugin.javaSignatureProvider + dokkaBasePlugin.signatureProvider providing ::JavadocSignatureProvider override kotinAsJavaPlugin.javaSignatureProvider } val rootCreator by extending { diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt index 2d0219a3..91e8189b 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.OutputWriter import org.jetbrains.dokka.base.resolvers.local.LocationProvider import org.jetbrains.dokka.javadoc.JavadocPlugin @@ -24,8 +25,9 @@ import java.time.LocalDate typealias TemplateMap = Map<String, Any?> -class KorteJavadocRenderer(private val outputWriter: OutputWriter, val context: DokkaContext, resourceDir: String) : +class KorteJavadocRenderer(val context: DokkaContext, resourceDir: String) : Renderer { + private val outputWriter: OutputWriter = context.plugin<DokkaBase>().querySingle { outputWriter } private lateinit var locationProvider: JavadocLocationProvider private val registeredPreprocessors = context.plugin<JavadocPlugin>().query { javadocPreprocessors } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt index 735309fc..e8ec0933 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt @@ -2,6 +2,7 @@ package org.jetbrains.dokka.javadoc.signatures import org.jetbrains.dokka.javadoc.translators.documentables.JavadocPageContentBuilder import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.signatures.JvmSignatureUtils import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter @@ -13,11 +14,17 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.utilities.DokkaLogger class JavadocSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider, JvmSignatureUtils by JavaSignatureUtils { - + constructor(context: DokkaContext) : this( + context.plugin<DokkaBase>().querySingle { commentsToContentConverter }, + context.logger + ) private val contentBuilder = JavadocPageContentBuilder(ctcc, this, logger) private val ignoredVisibilities = setOf(JavaVisibility.Default) |