diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-01-27 09:34:16 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-01-31 15:07:06 +0100 |
commit | 885ecd28153b484277c9ddcbf4a7f9d761a59545 (patch) | |
tree | db453e66762ebebb3ee05c0301b38c4465ea20a3 /plugins/mathjax/src | |
parent | c29605d92d1999434ecc79e774281a8280ae2823 (diff) | |
download | dokka-885ecd28153b484277c9ddcbf4a7f9d761a59545.tar.gz dokka-885ecd28153b484277c9ddcbf4a7f9d761a59545.tar.bz2 dokka-885ecd28153b484277c9ddcbf4a7f9d761a59545.zip |
Unifing model for pages with content ant technical renderer specific pages
Diffstat (limited to 'plugins/mathjax/src')
-rw-r--r-- | plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 32294ea8..52723157 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -3,9 +3,9 @@ package org.jetbrains.dokka.mathjax import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.pages.ModulePageNode +import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.transformers.pages.PageNodeTransformer @@ -19,17 +19,13 @@ private const val ANNOTATION = "usesMathJax" private const val LIB_PATH = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" object MathjaxTransformer : PageNodeTransformer { - override fun invoke(input: ModulePageNode, dokkaContext: DokkaContext) = input.modified( - children = input.children.map { transform(it) } - ) - - private fun transform(input: PageNode): PageNode = input.modified( - embeddedResources = input.embeddedResources + if (input.isNeedingMathjax) listOf(LIB_PATH) else emptyList(), - children = input.children.map { transform(it) } - ) - + override fun invoke(input: RootPageNode) = input.transformContentPagesTree { + it.modified( + embeddedResources = it.embeddedResources + if (it.isNeedingMathjax) listOf(LIB_PATH) else emptyList() + ) + } - private val PageNode.isNeedingMathjax + private val ContentPage.isNeedingMathjax get() = documentable?.platformInfo ?.flatMap { it.documentationNode.children } .orEmpty() |