diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2020-10-05 10:24:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 10:24:06 +0200 |
commit | 49d4757acd8e6ef974baccbb228a76ceb74b59b0 (patch) | |
tree | 09ff129568a53a833476763da1c93910e470fc15 /plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt | |
parent | 249556460973007de3d436ddda1df7d100aefab0 (diff) | |
download | dokka-49d4757acd8e6ef974baccbb228a76ceb74b59b0.tar.gz dokka-49d4757acd8e6ef974baccbb228a76ceb74b59b0.tar.bz2 dokka-49d4757acd8e6ef974baccbb228a76ceb74b59b0.zip |
Render react resources as separate css to allow overriding (#1416)
* Render react resources as separate css to allow overriding
* Improve build.gradle.kts
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 1afb5569..a5fca92f 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -62,7 +62,8 @@ object NavigationPageInstaller : PageTransformer { name = "scripts/navigation-pane.json", children = emptyList(), strategy = RenderingStrategy.LocationResolvableWrite { resolver -> - mapper.writeValueAsString(nodes.withDescendants().map { NavigationNodeView.from(it, resolver(it.dri, it.sourceSets)) }) + mapper.writeValueAsString( + nodes.withDescendants().map { NavigationNodeView.from(it, resolver(it.dri, it.sourceSets)) }) }) return input.modified( @@ -88,27 +89,53 @@ object NavigationPageInstaller : PageTransformer { }.sortedBy { it.name.toLowerCase() } } -object ResourceInstaller : PageTransformer { - override fun invoke(input: RootPageNode) = input.modified(children = input.children + resourcePages) - - private val resourcePages = listOf("styles", "scripts", "images").map { - RendererSpecificResourcePage(it, emptyList(), RenderingStrategy.Copy("/dokka/$it")) +object ScriptsInstaller : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { + return input.modified( + children = input.children + RendererSpecificResourcePage( + "scripts", + emptyList(), + RenderingStrategy.Copy("/dokka/scripts") + ) + ).transformContentPagesTree { + it.modified( + embeddedResources = it.embeddedResources + listOf( + "scripts/navigationLoader.js", + "scripts/platformContentHandler.js", + "scripts/sourceset_dependencies.js", + "scripts/clipboard.js", + ) + ) + } } } -object StyleAndScriptsAppender : PageTransformer { - override fun invoke(input: RootPageNode) = input.transformContentPagesTree { - it.modified( - embeddedResources = it.embeddedResources + listOf( - "styles/style.css", - "scripts/navigationLoader.js", - "scripts/platformContentHandler.js", - "scripts/sourceset_dependencies.js", - "scripts/clipboard.js", - "styles/jetbrains-mono.css" +object StylesInstaller : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode = + input.modified( + children = input.children + RendererSpecificResourcePage( + "styles", + emptyList(), + RenderingStrategy.Copy("/dokka/styles") + ) + ).transformContentPagesTree { + it.modified( + embeddedResources = it.embeddedResources + listOf( + "styles/style.css", + "styles/jetbrains-mono.css" + ) ) + } +} + +object AssetsInstaller : PageTransformer { + override fun invoke(input: RootPageNode) = input.modified( + children = input.children + RendererSpecificResourcePage( + "images", + emptyList(), + RenderingStrategy.Copy("/dokka/images") ) - } + ) } class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer { @@ -118,11 +145,13 @@ class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer { }.toMap() fun createDependenciesJson(): String = "sourceset_dependencies = '{${ - dependenciesMap.entries.joinToString(", ") { - "\"${it.key}\": [${it.value.joinToString(",") { - "\"$it\"" - }}]" - } + dependenciesMap.entries.joinToString(", ") { + "\"${it.key}\": [${ + it.value.joinToString(",") { + "\"$it\"" + } + }]" + } }}'" val deps = RendererSpecificResourcePage( |