aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-10-18 23:04:26 +0200
committerBłażej Kardyś <bkardys@virtuslab.com>2020-11-09 14:56:24 +0100
commitbe80016c77e9b98a75d8e832dd5723737f0e1d72 (patch)
treed4a1124e9278fcfb3a1c1b00cf743d8553ded011 /plugins
parent1aba0ec4973d7915caa93f1e9b3146ad82111903 (diff)
downloaddokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.tar.gz
dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.tar.bz2
dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.zip
Cleaning querying from plugins where possible
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt40
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt12
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt13
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt3
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt10
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt11
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt8
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt15
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt7
-rw-r--r--plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt12
-rw-r--r--plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt12
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocDocumentableToPageTranslator.kt11
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt11
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt33
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt4
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt9
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt17
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt10
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt14
19 files changed, 124 insertions, 128 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index c7e05e8f..a5d45282 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -24,7 +24,6 @@ import org.jetbrains.dokka.base.transformers.pages.samples.DefaultSamplesTransfo
import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransformer
import org.jetbrains.dokka.base.translators.descriptors.DefaultDescriptorToDocumentableTranslator
import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentableToPageTranslator
-import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.base.translators.psi.DefaultPsiToDocumentableTranslator
import org.jetbrains.dokka.plugability.DokkaPlugin
import org.jetbrains.dokka.transformers.pages.PageTransformer
@@ -42,15 +41,11 @@ class DokkaBase : DokkaPlugin() {
val descriptorToDocumentableTranslator by extending {
- CoreExtensions.sourceToDocumentableTranslator providing { ctx ->
- DefaultDescriptorToDocumentableTranslator(ctx.single(kotlinAnalysis))
- }
+ CoreExtensions.sourceToDocumentableTranslator providing ::DefaultDescriptorToDocumentableTranslator
}
val psiToDocumentableTranslator by extending {
- CoreExtensions.sourceToDocumentableTranslator providing { ctx ->
- DefaultPsiToDocumentableTranslator(ctx.single(kotlinAnalysis))
- }
+ CoreExtensions.sourceToDocumentableTranslator providing ::DefaultPsiToDocumentableTranslator
}
val documentableMerger by extending {
@@ -80,17 +75,11 @@ class DokkaBase : DokkaPlugin() {
}
val modulesAndPackagesDocumentation by extending {
- CoreExtensions.preMergeDocumentableTransformer providing { ctx ->
- ModuleAndPackageDocumentationTransformer(
- ModuleAndPackageDocumentationReader(ctx, ctx.single(kotlinAnalysis))
- )
- }
+ CoreExtensions.preMergeDocumentableTransformer providing ::ModuleAndPackageDocumentationTransformer
}
val kotlinSignatureProvider by extending {
- signatureProvider providing { ctx ->
- KotlinSignatureProvider(ctx.single(commentsToContentConverter), ctx.logger)
- }
+ signatureProvider providing ::KotlinSignatureProvider
}
val sinceKotlinTransformer by extending {
@@ -111,13 +100,7 @@ class DokkaBase : DokkaPlugin() {
}
val documentableToPageTranslator by extending {
- CoreExtensions.documentableToPageTranslator providing { ctx ->
- DefaultDocumentableToPageTranslator(
- ctx.single(commentsToContentConverter),
- ctx.single(signatureProvider),
- ctx.logger
- )
- }
+ CoreExtensions.documentableToPageTranslator providing ::DefaultDocumentableToPageTranslator
}
val docTagToContentConverter by extending {
@@ -125,7 +108,7 @@ class DokkaBase : DokkaPlugin() {
}
val pageMerger by extending {
- CoreExtensions.pageTransformer providing { ctx -> PageMerger(ctx[pageMergerStrategy]) }
+ CoreExtensions.pageTransformer providing ::PageMerger
}
val sourceSetMerger by extending {
@@ -182,16 +165,7 @@ class DokkaBase : DokkaPlugin() {
}
val sourceLinksTransformer by extending {
- htmlPreprocessors providing {
- SourceLinksTransformer(
- it,
- PageContentBuilder(
- it.single(commentsToContentConverter),
- it.single(signatureProvider),
- it.logger
- )
- )
- } order { after(rootCreator) }
+ htmlPreprocessors providing ::SourceLinksTransformer order { after(rootCreator) }
}
val navigationPageInstaller by extending {
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 6273e789..7f29e032 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -2,6 +2,7 @@ package org.jetbrains.dokka.base.signatures
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.Platform
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.signatures.KotlinSignatureUtils.dri
import org.jetbrains.dokka.base.signatures.KotlinSignatureUtils.driOrNull
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
@@ -14,11 +15,18 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.TextStyle
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.utilities.DokkaLogger
import kotlin.text.Typography.nbsp
-class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider,
- JvmSignatureUtils by KotlinSignatureUtils {
+class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger)
+ : SignatureProvider, JvmSignatureUtils by KotlinSignatureUtils {
+ constructor(context: DokkaContext) : this(
+ context.plugin<DokkaBase>().querySingle { commentsToContentConverter },
+ context.logger
+ )
private val contentBuilder = PageContentBuilder(ctcc, this, logger)
private val ignoredVisibilities = setOf(JavaVisibility.Public, KotlinVisibility.Public)
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt
index 6e26377e..b74242c3 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt
@@ -4,6 +4,7 @@ package org.jetbrains.dokka.base.transformers.documentables
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.analysis.KotlinAnalysis
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentation.Classifier
import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentationFragment
import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumentationParsingContext
@@ -15,6 +16,8 @@ import org.jetbrains.dokka.model.SourceSetDependent
import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.model.doc.Deprecated
import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.utilities.associateWithNotNull
internal interface ModuleAndPackageDocumentationReader {
@@ -22,15 +25,15 @@ internal interface ModuleAndPackageDocumentationReader {
operator fun get(pkg: DPackage): SourceSetDependent<DocumentationNode>
}
-internal fun ModuleAndPackageDocumentationReader(
- context: DokkaContext, kotlinAnalysis: KotlinAnalysis? = null
-): ModuleAndPackageDocumentationReader = ContextModuleAndPackageDocumentationReader(context, kotlinAnalysis)
+internal fun ModuleAndPackageDocumentationReader(context: DokkaContext): ModuleAndPackageDocumentationReader =
+ ContextModuleAndPackageDocumentationReader(context)
private class ContextModuleAndPackageDocumentationReader(
- private val context: DokkaContext,
- private val kotlinAnalysis: KotlinAnalysis?
+ private val context: DokkaContext
) : ModuleAndPackageDocumentationReader {
+ private val kotlinAnalysis: KotlinAnalysis = context.plugin<DokkaBase>().querySingle { kotlinAnalysis }
+
private val documentationFragments: SourceSetDependent<List<ModuleAndPackageDocumentationFragment>> =
context.configuration.sourceSets.associateWith { sourceSet ->
sourceSet.includes.flatMap { include -> parseModuleAndPackageDocumentationFragments(include) }
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt
index 2b2a3f03..99fba9f7 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt
@@ -4,12 +4,15 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.model.SourceSetDependent
import org.jetbrains.dokka.model.doc.DocumentationNode
+import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer
internal class ModuleAndPackageDocumentationTransformer(
private val moduleAndPackageDocumentationReader: ModuleAndPackageDocumentationReader
) : PreMergeDocumentableTransformer {
+ constructor(context: DokkaContext) : this(ModuleAndPackageDocumentationReader(context))
+
override fun invoke(modules: List<DModule>): List<DModule> {
return modules.map { module ->
module.copy(
diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt
index 4faf3ad4..c1f1a7f5 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt
@@ -1,10 +1,18 @@
package org.jetbrains.dokka.base.transformers.pages.merger
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RootPageNode
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.query
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.transformers.pages.PageTransformer
-class PageMerger(private val strategies: Iterable<PageMergerStrategy>) : PageTransformer {
+class PageMerger(context: DokkaContext) : PageTransformer {
+
+ private val strategies: Iterable<PageMergerStrategy> = context.plugin<DokkaBase>().query { pageMergerStrategy }
+
override fun invoke(input: RootPageNode): RootPageNode =
input.modified(children = input.children.map { it.mergeChildren(emptyList()) })
diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index 2c6d301c..4f2d23c7 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -8,18 +8,27 @@ import org.jetbrains.dokka.model.DocumentableSource
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.analysis.DescriptorDocumentableSource
import org.jetbrains.dokka.analysis.PsiDocumentableSource
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.model.WithSources
import org.jetbrains.dokka.model.toDisplaySourceSets
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.transformers.pages.PageTransformer
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.utils.addToStdlib.cast
import java.io.File
-class SourceLinksTransformer(val context: DokkaContext, val builder: PageContentBuilder) : PageTransformer {
+class SourceLinksTransformer(val context: DokkaContext) : PageTransformer {
+
+ private val builder : PageContentBuilder = PageContentBuilder(
+ context.plugin<DokkaBase>().querySingle { commentsToContentConverter },
+ context.plugin<DokkaBase>().querySingle { signatureProvider },
+ context.logger
+ )
override fun invoke(input: RootPageNode) =
input.transformContentPagesTree { node ->
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 8db3aa43..f388ee44 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -7,6 +7,7 @@ import org.jetbrains.dokka.analysis.DescriptorDocumentableSource
import org.jetbrains.dokka.analysis.DokkaResolutionFacade
import org.jetbrains.dokka.analysis.KotlinAnalysis
import org.jetbrains.dokka.analysis.from
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.parsers.MarkdownParser
import org.jetbrains.dokka.base.translators.isDirectlyAnException
import org.jetbrains.dokka.links.*
@@ -17,6 +18,9 @@ import org.jetbrains.dokka.model.TypeConstructor
import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.query
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator
import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
@@ -60,9 +64,11 @@ import org.jetbrains.kotlin.resolve.constants.EnumValue as ConstantsEnumValue
import org.jetbrains.kotlin.resolve.constants.KClassValue as ConstantsKtClassValue
class DefaultDescriptorToDocumentableTranslator(
- private val kotlinAnalysis: KotlinAnalysis
+ context: DokkaContext
) : SourceToDocumentableTranslator {
+ private val kotlinAnalysis: KotlinAnalysis = context.plugin<DokkaBase>().querySingle { kotlinAnalysis }
+
override suspend fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule {
val (environment, facade) = kotlinAnalysis[sourceSet]
val packageFragments = environment.getSourceFiles().asSequence()
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt
index 04251947..2aa3e2dc 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt
@@ -1,17 +1,20 @@
package org.jetbrains.dokka.base.translators.documentables
-import org.jetbrains.dokka.base.signatures.SignatureProvider
-import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.pages.ModulePageNode
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator
-import org.jetbrains.dokka.utilities.DokkaLogger
class DefaultDocumentableToPageTranslator(
- private val commentsToContentConverter: CommentsToContentConverter,
- private val signatureProvider: SignatureProvider,
- private val logger: DokkaLogger
+ context: DokkaContext
) : DocumentableToPageTranslator {
+ private val commentsToContentConverter = context.plugin<DokkaBase>().querySingle { commentsToContentConverter }
+ private val signatureProvider = context.plugin<DokkaBase>().querySingle { signatureProvider }
+ private val logger = context.logger
+
override fun invoke(module: DModule): ModulePageNode =
DefaultPageCreator(commentsToContentConverter, signatureProvider, logger).pageForModule(module)
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index f46f11c9..00fab531 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -13,6 +13,7 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.analysis.KotlinAnalysis
import org.jetbrains.dokka.analysis.PsiDocumentableSource
import org.jetbrains.dokka.analysis.from
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.translators.isDirectlyAnException
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.nextTarget
@@ -22,6 +23,8 @@ import org.jetbrains.dokka.model.doc.DocumentationNode
import org.jetbrains.dokka.model.doc.Param
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator
import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.dokka.utilities.parallelForEach
@@ -46,9 +49,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import java.io.File
class DefaultPsiToDocumentableTranslator(
- private val kotlinAnalysis: KotlinAnalysis
+ context: DokkaContext
) : SourceToDocumentableTranslator {
+ private val kotlinAnalysis: KotlinAnalysis = context.plugin<DokkaBase>().querySingle { kotlinAnalysis }
+
override suspend fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule {
return coroutineScope {
fun isFileInSourceRoots(file: File): Boolean =
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index 7e8bde49..11896101 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -1,15 +1,12 @@
package linkableContent
import org.jetbrains.dokka.SourceLinkDefinitionImpl
-import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.transformers.pages.samples.DefaultSamplesTransformer
import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransformer
-import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.model.WithGenerics
import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.model.doc.Text
import org.jetbrains.dokka.pages.*
-import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -127,14 +124,7 @@ class LinkableContentTest : AbstractCoreTest() {
testFromData(configuration) {
renderingStage = { rootPageNode, dokkaContext ->
- val newRoot = SourceLinksTransformer(
- dokkaContext,
- PageContentBuilder(
- dokkaContext.single(dokkaContext.plugin<DokkaBase>().commentsToContentConverter),
- dokkaContext.single(dokkaContext.plugin<DokkaBase>().signatureProvider),
- dokkaContext.logger
- )
- ).invoke(rootPageNode)
+ val newRoot = SourceLinksTransformer(dokkaContext).invoke(rootPageNode)
val moduleChildren = newRoot.children
Assertions.assertEquals(1, moduleChildren.size)
val packageChildren = moduleChildren.first().children
diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt
index 2aba6d67..a3069107 100644
--- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt
+++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt
@@ -10,9 +10,11 @@ import org.jetbrains.dokka.utilities.DokkaConsoleLogger
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
import testApi.testRunner.TestDokkaConfigurationBuilder
import testApi.testRunner.dModule
import testApi.testRunner.dPackage
+import java.lang.IllegalStateException
class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAndPackageDocumentationReaderTest() {
@@ -110,13 +112,11 @@ class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAnd
@Test
fun `assert moduleA with unknown source set`() {
- val documentation = reader[
- dModule("moduleA", sourceSets = setOf(configurationBuilder.unattachedSourceSet { name = "unknown" }))
- ]
- assertEquals(
- emptyMap<DokkaSourceSet, DocumentationNode>(), documentation,
+ assertThrows<IllegalStateException>(
"Expected no documentation received for module with unknown sourceSet"
- )
+ ) { reader[
+ dModule("moduleA", sourceSets = setOf(configurationBuilder.unattachedSourceSet { name = "unknown" }))
+ ]}
}
@Test
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)
diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt
index 04a63fca..b390751c 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt
@@ -12,19 +12,12 @@ class KotlinAsJavaPlugin : DokkaPlugin() {
CoreExtensions.documentableTransformer with KotlinAsJavaDocumentableTransformer()
}
val javaSignatureProvider by extending {
- val dokkaBasePlugin = plugin<DokkaBase>()
- dokkaBasePlugin.signatureProvider providing { ctx ->
- JavaSignatureProvider(ctx.single(dokkaBasePlugin.commentsToContentConverter), ctx.logger)
- } override dokkaBasePlugin.kotlinSignatureProvider
+ with(plugin<DokkaBase>()) {
+ signatureProvider providing ::JavaSignatureProvider override kotlinSignatureProvider
+ }
}
val kotlinAsJavaDocumentableToPageTranslator by extending {
- val dokkaBasePlugin = plugin<DokkaBase>()
- CoreExtensions.documentableToPageTranslator providing { ctx ->
- KotlinAsJavaDocumentableToPageTranslator(
- ctx.single(dokkaBasePlugin.commentsToContentConverter),
- ctx.single(dokkaBasePlugin.signatureProvider),
- ctx.logger
- )
- } override dokkaBasePlugin.documentableToPageTranslator
+ CoreExtensions.documentableToPageTranslator providing ::KotlinAsJavaDocumentableToPageTranslator override
+ plugin<DokkaBase>().documentableToPageTranslator
}
} \ No newline at end of file
diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
index 1d62a206..60c2e5cc 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.kotlinAsJava.signatures
+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
@@ -11,11 +12,18 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.TextStyle
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.utilities.DokkaLogger
import kotlin.text.Typography.nbsp
-class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider,
+class JavaSignatureProvider internal constructor(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider,
JvmSignatureUtils by JavaSignatureUtils {
+ constructor(context: DokkaContext) : this(
+ context.plugin<DokkaBase>().querySingle { commentsToContentConverter },
+ context.logger
+ )
private val contentBuilder = PageContentBuilder(ctcc, this, logger)
private val ignoredVisibilities = setOf(JavaVisibility.Default)
diff --git a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt
index cfb4daa3..ac526d57 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt
@@ -1,17 +1,21 @@
package org.jetbrains.dokka.kotlinAsJava.translators
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.signatures.SignatureProvider
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator
import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.pages.ModulePageNode
+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 KotlinAsJavaDocumentableToPageTranslator(
- private val commentsToContentConverter: CommentsToContentConverter,
- private val signatureProvider: SignatureProvider,
- private val logger: DokkaLogger
-) : DocumentableToPageTranslator {
+class KotlinAsJavaDocumentableToPageTranslator(context: DokkaContext) : DocumentableToPageTranslator {
+ private val commentsToContentConverter = context.plugin<DokkaBase>().querySingle { commentsToContentConverter }
+ private val signatureProvider = context.plugin<DokkaBase>().querySingle { signatureProvider }
+ private val logger: DokkaLogger = context.logger
+
override fun invoke(module: DModule): ModulePageNode =
KotlinAsJavaPageCreator(commentsToContentConverter, signatureProvider, logger).pageForModule(module)
} \ No newline at end of file