diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-07-01 17:36:50 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-07-07 10:07:21 +0200 |
commit | 0533ef9a56ae34138a3f8a5e996805713c48c384 (patch) | |
tree | 9130b79b048feb003b704d0f5024809037944bf2 /plugins | |
parent | 177ede83228515f03436a4ac0ce1ce573fc3d74b (diff) | |
download | dokka-0533ef9a56ae34138a3f8a5e996805713c48c384.tar.gz dokka-0533ef9a56ae34138a3f8a5e996805713c48c384.tar.bz2 dokka-0533ef9a56ae34138a3f8a5e996805713c48c384.zip |
Add overrides to provided plugins
Diffstat (limited to 'plugins')
5 files changed, 45 insertions, 33 deletions
diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt index 46ada43a..83f1d180 100644 --- a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt +++ b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt @@ -3,15 +3,20 @@ package utils import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.OutputWriter import org.jetbrains.dokka.plugability.DokkaPlugin -import java.io.File -class TestOutputWriterPlugin(failOnOverwrite: Boolean = true): DokkaPlugin() { +class TestOutputWriterPlugin(failOnOverwrite: Boolean = true) : DokkaPlugin() { val writer = TestOutputWriter(failOnOverwrite) - val testWriter by extending { plugin<DokkaBase>().outputWriter with writer } + private val dokkaBase by lazy { plugin<DokkaBase>() } + + val testWriter by extending { + (dokkaBase.outputWriter + with writer + override dokkaBase.fileWriter) + } } -class TestOutputWriter(private val failOnOverwrite: Boolean = true): OutputWriter { +class TestOutputWriter(private val failOnOverwrite: Boolean = true) : OutputWriter { val contents: Map<String, String> get() = _contents private val _contents = mutableMapOf<String, String>() @@ -23,5 +28,6 @@ class TestOutputWriter(private val failOnOverwrite: Boolean = true): OutputWrite } } - override suspend fun writeResources(pathFrom: String, pathTo: String) = write(pathTo, "*** content of $pathFrom ***", "") + override suspend fun writeResources(pathFrom: String, pathTo: String) = + write(pathTo, "*** content of $pathFrom ***", "") } diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt index 287ef74f..32c0b7b7 100644 --- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt @@ -19,12 +19,20 @@ class GfmPlugin : DokkaPlugin() { val gfmPreprocessors by extensionPoint<PageTransformer>() + private val dokkaBase by lazy { plugin<DokkaBase>() } + val renderer by extending { - CoreExtensions.renderer providing { CommonmarkRenderer(it) } applyIf { format == "gfm" } + (CoreExtensions.renderer + providing { CommonmarkRenderer(it) } + applyIf { format == "gfm" } + override dokkaBase.htmlRenderer) } val locationProvider by extending { - plugin<DokkaBase>().locationProviderFactory providing { MarkdownLocationProviderFactory(it) } applyIf { format == "gfm" } + (dokkaBase.locationProviderFactory + providing { MarkdownLocationProviderFactory(it) } + applyIf { format == "gfm" } + override dokkaBase.locationProvider) } val rootCreator by extending { @@ -32,13 +40,9 @@ class GfmPlugin : DokkaPlugin() { } val packageListCreator by extending { - gfmPreprocessors providing { - PackageListCreator( - it, - "gfm", - "md" - ) - } order { after(rootCreator) } + (gfmPreprocessors + providing { PackageListCreator(it, "gfm", "md") } + order { after(rootCreator) }) } } @@ -128,7 +132,7 @@ open class CommonmarkRenderer( sourceSets: Set<DokkaSourceSet>, pageContext: ContentPage, ) { - if(content is ContentGroup && content.children.firstOrNull{ it is ContentTable } != null){ + if (content is ContentGroup && content.children.firstOrNull { it is ContentTable } != null) { buildContentNode(content, pageContext) } else { val distinct = sourceSets.map { @@ -155,11 +159,16 @@ open class CommonmarkRenderer( pageContext: ContentPage, sourceSetRestriction: Set<DokkaSourceSet>? ) { - if(node.dci.kind == ContentKind.Sample || node.dci.kind == ContentKind.Parameters){ - node.sourceSets.forEach {sourcesetData -> + if (node.dci.kind == ContentKind.Sample || node.dci.kind == ContentKind.Parameters) { + node.sourceSets.forEach { sourcesetData -> append("${sourcesetData.moduleDisplayName}/${sourcesetData.sourceSetID}") buildNewLine() - buildTable(node.copy(children = node.children.filter { it.sourceSets.contains(sourcesetData) }, dci = node.dci.copy(kind = ContentKind.Main)), pageContext, sourceSetRestriction) + buildTable( + node.copy( + children = node.children.filter { it.sourceSets.contains(sourcesetData) }, + dci = node.dci.copy(kind = ContentKind.Main) + ), pageContext, sourceSetRestriction + ) buildNewLine() } } else { diff --git a/plugins/javadoc/src/main/kotlin/javadoc/JavadocPlugin.kt b/plugins/javadoc/src/main/kotlin/javadoc/JavadocPlugin.kt index 6e467542..7b4aa64d 100644 --- a/plugins/javadoc/src/main/kotlin/javadoc/JavadocPlugin.kt +++ b/plugins/javadoc/src/main/kotlin/javadoc/JavadocPlugin.kt @@ -15,13 +15,10 @@ class JavadocPlugin : DokkaPlugin() { val locationProviderFactory by extensionPoint<JavadocLocationProviderFactory>() val dokkaJavadocPlugin by extending { - CoreExtensions.renderer providing { ctx -> - KorteJavadocRenderer( - dokkaBasePlugin.querySingle { outputWriter }, - ctx, - "views" - ) - } applyIf { format == "javadoc" } + (CoreExtensions.renderer + providing { ctx -> KorteJavadocRenderer(dokkaBasePlugin.querySingle { outputWriter }, ctx, "views") } + applyIf { format == "javadoc" } + override dokkaBasePlugin.htmlRenderer) } val pageTranslator by extending { @@ -31,7 +28,7 @@ class JavadocPlugin : DokkaPlugin() { dokkaBasePlugin.querySingle { signatureProvider }, context.logger ) - } + } override dokkaBasePlugin.documentableToPageTranslator } val javadocLocationProviderFactory by extending { diff --git a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt index b9f5e1a5..ad83ca76 100644 --- a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt +++ b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka.jekyll import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.PackageListCreator import org.jetbrains.dokka.base.renderers.RootCreator import org.jetbrains.dokka.gfm.CommonmarkRenderer @@ -18,7 +19,10 @@ class JekyllPlugin : DokkaPlugin() { val jekyllPreprocessors by extensionPoint<PageTransformer>() val renderer by extending { - CoreExtensions.renderer providing { JekyllRenderer(it) } applyIf { format == "jekyll" } + (CoreExtensions.renderer + providing { JekyllRenderer(it) } + applyIf { format == "jekyll" } + override plugin<DokkaBase>().htmlRenderer) } val rootCreator by extending { diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt index bf9b8dc0..5f06852e 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt @@ -13,11 +13,7 @@ class KotlinAsJavaPlugin : DokkaPlugin() { val javaSignatureProvider by extending { val dokkaBasePlugin = plugin<DokkaBase>() dokkaBasePlugin.signatureProvider providing { ctx -> - JavaSignatureProvider( - ctx.single( - dokkaBasePlugin.commentsToContentConverter - ), ctx.logger - ) - } + JavaSignatureProvider(ctx.single(dokkaBasePlugin.commentsToContentConverter), ctx.logger) + } override dokkaBasePlugin.kotlinSignatureProvider } }
\ No newline at end of file |