aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt172
1 files changed, 0 insertions, 172 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
deleted file mode 100644
index dad013e2..00000000
--- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka.base.renderers.html
-
-import org.jetbrains.dokka.base.DokkaBase
-import org.jetbrains.dokka.base.DokkaBaseConfiguration
-import org.jetbrains.dokka.base.templating.AddToSourcesetDependencies
-import org.jetbrains.dokka.base.templating.toJsonString
-import org.jetbrains.dokka.pages.RendererSpecificResourcePage
-import org.jetbrains.dokka.pages.RenderingStrategy
-import org.jetbrains.dokka.pages.RootPageNode
-import org.jetbrains.dokka.plugability.DokkaContext
-import org.jetbrains.dokka.plugability.configuration
-import org.jetbrains.dokka.transformers.pages.PageTransformer
-
-public open class NavigationPageInstaller(
- public val context: DokkaContext
-) : NavigationDataProvider(context), PageTransformer {
- override fun invoke(input: RootPageNode): RootPageNode =
- input.modified(
- children = input.children + NavigationPage(
- root = navigableChildren(input),
- moduleName = context.configuration.moduleName,
- context = context
- )
- )
-}
-
-public class CustomResourceInstaller(
- public val dokkaContext: DokkaContext
-) : PageTransformer {
- private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(dokkaContext)
-
- private val customAssets = configuration?.customAssets?.map {
- RendererSpecificResourcePage("images/${it.name}", emptyList(), RenderingStrategy.Copy(it.absolutePath))
- }.orEmpty()
-
- private val customStylesheets = configuration?.customStyleSheets?.map {
- RendererSpecificResourcePage("styles/${it.name}", emptyList(), RenderingStrategy.Copy(it.absolutePath))
- }.orEmpty()
-
- override fun invoke(input: RootPageNode): RootPageNode {
- val customResourcesPaths = (customAssets + customStylesheets).map { it.name }.toSet()
- val withEmbeddedResources =
- input.transformContentPagesTree { it.modified(embeddedResources = it.embeddedResources + customResourcesPaths) }
- if(dokkaContext.configuration.delayTemplateSubstitution)
- return withEmbeddedResources
- val (currentResources, otherPages) = withEmbeddedResources.children.partition { it is RendererSpecificResourcePage }
- return input.modified(children = otherPages + currentResources.filterNot { it.name in customResourcesPaths } + customAssets + customStylesheets)
- }
-}
-
-public class ScriptsInstaller(private val dokkaContext: DokkaContext) : PageTransformer {
-
- // scripts ending with `_deferred.js` are loaded with `defer`, otherwise `async`
- private val scriptsPages = listOf(
- "scripts/clipboard.js",
- "scripts/navigation-loader.js",
- "scripts/platform-content-handler.js",
- "scripts/main.js",
- "scripts/prism.js",
-
- // It's important for this script to be deferred because it has logic that makes decisions based on
- // rendered elements (for instance taking their clientWidth), and if not all styles are loaded/applied
- // at the time of inspecting them, it will give incorrect results and might lead to visual bugs.
- // should be easy to test if you open any page in incognito or by reloading it (Ctrl+Shift+R)
- "scripts/symbol-parameters-wrapper_deferred.js",
- )
-
- override fun invoke(input: RootPageNode): RootPageNode =
- input.let { root ->
- if (dokkaContext.configuration.delayTemplateSubstitution) root
- else root.modified(children = input.children + scriptsPages.toRenderSpecificResourcePage())
- }.transformContentPagesTree {
- it.modified(
- embeddedResources = it.embeddedResources + scriptsPages
- )
- }
-}
-
-public class StylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer {
- private val stylesPages = listOf(
- "styles/style.css",
- "styles/main.css",
- "styles/prism.css",
- "styles/logo-styles.css",
- "styles/font-jb-sans-auto.css"
- )
-
- override fun invoke(input: RootPageNode): RootPageNode =
- input.let { root ->
- if (dokkaContext.configuration.delayTemplateSubstitution) root
- else root.modified(children = input.children + stylesPages.toRenderSpecificResourcePage())
- }.transformContentPagesTree {
- it.modified(
- embeddedResources = it.embeddedResources + stylesPages
- )
- }
-}
-
-public object AssetsInstaller : PageTransformer {
- private val imagesPages = listOf(
- "images/arrow_down.svg",
- "images/logo-icon.svg",
- "images/go-to-top-icon.svg",
- "images/footer-go-to-link.svg",
- "images/anchor-copy-button.svg",
- "images/copy-icon.svg",
- "images/copy-successful-icon.svg",
- "images/theme-toggle.svg",
- "images/burger.svg",
- "images/homepage.svg",
-
- // navigation icons
- "images/nav-icons/abstract-class.svg",
- "images/nav-icons/abstract-class-kotlin.svg",
- "images/nav-icons/annotation.svg",
- "images/nav-icons/annotation-kotlin.svg",
- "images/nav-icons/class.svg",
- "images/nav-icons/class-kotlin.svg",
- "images/nav-icons/enum.svg",
- "images/nav-icons/enum-kotlin.svg",
- "images/nav-icons/exception-class.svg",
- "images/nav-icons/field-value.svg",
- "images/nav-icons/field-variable.svg",
- "images/nav-icons/function.svg",
- "images/nav-icons/interface.svg",
- "images/nav-icons/interface-kotlin.svg",
- "images/nav-icons/object.svg",
- "images/nav-icons/typealias-kotlin.svg",
- )
-
- override fun invoke(input: RootPageNode): RootPageNode = input.modified(
- children = input.children + imagesPages.toRenderSpecificResourcePage()
- )
-}
-
-private fun List<String>.toRenderSpecificResourcePage(): List<RendererSpecificResourcePage> =
- map { RendererSpecificResourcePage(it, emptyList(), RenderingStrategy.Copy("/dokka/$it")) }
-
-public class SourcesetDependencyAppender(
- public val context: DokkaContext
-) : PageTransformer {
- private val name = "scripts/sourceset_dependencies.js"
- override fun invoke(input: RootPageNode): RootPageNode {
- val dependenciesMap = context.configuration.sourceSets.associate {
- it.sourceSetID to it.dependentSourceSets
- }
-
- fun createDependenciesJson(): String =
- dependenciesMap.map { (key, values) -> key.toString() to values.map { it.toString() } }.toMap()
- .let { content ->
- if (context.configuration.delayTemplateSubstitution) {
- toJsonString(AddToSourcesetDependencies(context.configuration.moduleName, content))
- } else {
- "sourceset_dependencies='${toJsonString(content)}'"
- }
- }
-
- val deps = RendererSpecificResourcePage(
- name = name,
- children = emptyList(),
- strategy = RenderingStrategy.Write(createDependenciesJson())
- )
-
- return input.modified(
- children = input.children + deps
- ).transformContentPagesTree { it.modified(embeddedResources = it.embeddedResources + name) }
- }
-}