From 9273d18c9edf7ea2aa265d53a9ae971e3e28a87d Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Fri, 14 Feb 2020 14:25:48 +0100 Subject: Add extension for html preprocessors --- .../main/kotlin/plugability/DefaultExtensions.kt | 0 plugins/base/src/main/kotlin/DokkaBase.kt | 24 +++++++++++++++++++++- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 11 ++++------ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 core/src/main/kotlin/plugability/DefaultExtensions.kt diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt new file mode 100644 index 00000000..e69de29b diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index d236aa01..8934dd7f 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -3,7 +3,7 @@ package org.jetbrains.dokka.base import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.renderers.FileWriter import org.jetbrains.dokka.base.renderers.OutputWriter -import org.jetbrains.dokka.base.renderers.html.HtmlRenderer +import org.jetbrains.dokka.base.renderers.html.* import org.jetbrains.dokka.base.resolvers.DefaultLocationProviderFactory import org.jetbrains.dokka.base.resolvers.LocationProviderFactory import org.jetbrains.dokka.base.signatures.KotlinSignatureProvider @@ -21,6 +21,7 @@ import org.jetbrains.dokka.base.translators.descriptors.DefaultDescriptorToDocum import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentableToPageTranslator import org.jetbrains.dokka.base.translators.psi.DefaultPsiToDocumentableTranslator import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.transformers.pages.PageTransformer class DokkaBase : DokkaPlugin() { val pageMergerStrategy by extensionPoint() @@ -28,6 +29,7 @@ class DokkaBase : DokkaPlugin() { val signatureProvider by extensionPoint() val locationProviderFactory by extensionPoint() val outputWriter by extensionPoint() + val htmlPreprocessors by extensionPoint() val descriptorToDocumentableTranslator by extending(isFallback = true) { CoreExtensions.descriptorToDocumentableTranslator providing ::DefaultDescriptorToDocumentableTranslator @@ -94,4 +96,24 @@ class DokkaBase : DokkaPlugin() { val fileWriter by extending(isFallback = true) { outputWriter providing ::FileWriter } + + val rootCreator by extending { + htmlPreprocessors with RootCreator + } + + val navigationPageInstaller by extending { + htmlPreprocessors with NavigationPageInstaller order { after(rootCreator) } + } + + val searchPageInstaller by extending { + htmlPreprocessors with SearchPageInstaller order { after(rootCreator) } + } + + val resourceInstaller by extending { + htmlPreprocessors with ResourceInstaller order { after(rootCreator) } + } + + val styleAndScriptsAppender by extending { + htmlPreprocessors with StyleAndScriptsAppender order { after(rootCreator) } + } } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 57915134..365405ed 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -2,11 +2,14 @@ package org.jetbrains.dokka.base.renderers.html import kotlinx.html.* import kotlinx.html.stream.createHTML +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.query import java.io.File open class HtmlRenderer( @@ -15,13 +18,7 @@ open class HtmlRenderer( private val pageList = mutableListOf() - override val preprocessors = listOf( - RootCreator, - SearchPageInstaller, - ResourceInstaller, - NavigationPageInstaller, - StyleAndScriptsAppender - ) + override val preprocessors = context.plugin().query { htmlPreprocessors } override fun FlowContent.wrapGroup( node: ContentGroup, -- cgit