From 87c65d1bf22dc0dbc6da8d007fafc73382432812 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Wed, 20 Nov 2019 08:09:59 +0100 Subject: Mathjax plugin implemented --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 35 ++++++++++++++++++++++ .../org.jetbrains.dokka.plugability.DokkaPlugin | 1 + 2 files changed, 36 insertions(+) create mode 100644 plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt create mode 100644 plugins/mathjax/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt new file mode 100644 index 00000000..63512966 --- /dev/null +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -0,0 +1,35 @@ +package org.jetbrains.dokka.mathjax + +import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.pages.ModulePageNode +import org.jetbrains.dokka.pages.PageNode +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.transformers.PageNodeTransformer + +class MathjaxPlugin : DokkaPlugin() { + val transformer by extending { + CoreExtensions.pageTransformer with MathjaxTransformer + } +} + +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) } + ) + + + private val PageNode.isNeedingMathjax + get() = documentationNode?.descriptors + ?.flatMap { it.docTag?.children?.toList().orEmpty() } + .orEmpty() + .any { it.text == ANNOTATION } +} \ No newline at end of file diff --git a/plugins/mathjax/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin b/plugins/mathjax/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin new file mode 100644 index 00000000..9f9736f3 --- /dev/null +++ b/plugins/mathjax/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin @@ -0,0 +1 @@ +org.jetbrains.dokka.mathjax.MathjaxPlugin -- cgit From 4b1a3a2cbe62f98c9f1b472e70d754645d7f8641 Mon Sep 17 00:00:00 2001 From: Błażej Kardyś Date: Tue, 26 Nov 2019 14:39:06 +0100 Subject: Merging PageNode changes with plugins --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 63512966..0decfb1c 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -28,7 +28,7 @@ object MathjaxTransformer : PageNodeTransformer { private val PageNode.isNeedingMathjax - get() = documentationNode?.descriptors + get() = documentationNode?.platformInfo ?.flatMap { it.docTag?.children?.toList().orEmpty() } .orEmpty() .any { it.text == ANNOTATION } -- cgit From a945617725e8df084270aacd5af76da2b911111e Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 25 Nov 2019 15:34:47 +0100 Subject: Interface segregation in plugins api --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 0decfb1c..b7b2d505 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -4,6 +4,7 @@ import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaContextConfiguration import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.transformers.PageNodeTransformer -- cgit From 49439594f86217d8a25e8df2580b8ef29d836230 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Tue, 26 Nov 2019 13:44:27 +0100 Subject: Introduction of all important extension points and restructuring of DokkaGenerator --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index b7b2d505..0c8bd654 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -4,9 +4,8 @@ import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.plugability.DokkaContextConfiguration import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.transformers.PageNodeTransformer +import org.jetbrains.dokka.transformers.pages.PageNodeTransformer class MathjaxPlugin : DokkaPlugin() { val transformer by extending { -- cgit From dd017a44ed7baae83f4f09a92d9691231f424eaa Mon Sep 17 00:00:00 2001 From: BarkingBad <32793002+BarkingBad@users.noreply.github.com> Date: Fri, 13 Dec 2019 14:01:25 +0100 Subject: Add abstract structure for MD/HTML comments and MD parser --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 0c8bd654..ff3e83a3 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -28,7 +28,7 @@ object MathjaxTransformer : PageNodeTransformer { private val PageNode.isNeedingMathjax - get() = documentationNode?.platformInfo + get() = documentable?.platformInfo ?.flatMap { it.docTag?.children?.toList().orEmpty() } .orEmpty() .any { it.text == ANNOTATION } -- cgit From 54f587baf12ecf8f0115cb406203df14c4d6ab5d Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 13 Dec 2019 14:27:25 +0100 Subject: Fix mathjax plugin for dokka to compile --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index ff3e83a3..9b3c25c2 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.mathjax +import model.doc.CustomTag import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PageNode @@ -29,7 +30,11 @@ object MathjaxTransformer : PageNodeTransformer { private val PageNode.isNeedingMathjax get() = documentable?.platformInfo - ?.flatMap { it.docTag?.children?.toList().orEmpty() } + ?.flatMap { it.documentationNode.children } .orEmpty() - .any { it.text == ANNOTATION } + .filterIsInstance() + .let { true } +// .any { it.name.contains("ref") && it.root.children.any {it.name} } + + } \ No newline at end of file -- cgit From 288431f21b18f5311de77c9afcb29346cb7c6498 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Fri, 13 Dec 2019 16:24:16 +0100 Subject: Changes naming and applies pull request's requirements --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 9b3c25c2..32294ea8 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka.mathjax -import model.doc.CustomTag + +import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PageNode @@ -14,7 +15,7 @@ class MathjaxPlugin : DokkaPlugin() { } } -private const val ANNOTATION = "@usesMathJax" +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 { @@ -32,9 +33,5 @@ object MathjaxTransformer : PageNodeTransformer { get() = documentable?.platformInfo ?.flatMap { it.documentationNode.children } .orEmpty() - .filterIsInstance() - .let { true } -// .any { it.name.contains("ref") && it.root.children.any {it.name} } - - + .any { (it as? CustomWrapperTag)?.name == ANNOTATION } } \ No newline at end of file -- cgit From 885ecd28153b484277c9ddcbf4a7f9d761a59545 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 27 Jan 2020 09:34:16 +0100 Subject: Unifing model for pages with content ant technical renderer specific pages --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'plugins/mathjax/src') 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() -- cgit From 1e0271e4e2888022f2ac93366c397d7315008c45 Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Thu, 6 Feb 2020 15:51:07 +0100 Subject: page merger strategy --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 52723157..0f66c77c 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -18,7 +18,7 @@ class MathjaxPlugin : DokkaPlugin() { 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 { +object MathjaxTransformer : PageNodeTransformer() { override fun invoke(input: RootPageNode) = input.transformContentPagesTree { it.modified( embeddedResources = it.embeddedResources + if (it.isNeedingMathjax) listOf(LIB_PATH) else emptyList() -- cgit From 519bc7969930f191fb7d9155b1c07f7e226e219f Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Tue, 11 Feb 2020 18:29:19 +0100 Subject: page merger strategy with tests --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 0f66c77c..52723157 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -18,7 +18,7 @@ class MathjaxPlugin : DokkaPlugin() { 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() { +object MathjaxTransformer : PageNodeTransformer { override fun invoke(input: RootPageNode) = input.transformContentPagesTree { it.modified( embeddedResources = it.embeddedResources + if (it.isNeedingMathjax) listOf(LIB_PATH) else emptyList() -- cgit From bee52be815bebd7012193728521636b5fbed2829 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 18 Feb 2020 17:47:14 +0100 Subject: Rename extensions to make them more uniform --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 52723157..cded0929 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -1,13 +1,12 @@ package org.jetbrains.dokka.mathjax -import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.pages.ContentPage -import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.transformers.pages.PageNodeTransformer +import org.jetbrains.dokka.transformers.pages.PageTransformer class MathjaxPlugin : DokkaPlugin() { val transformer by extending { @@ -18,7 +17,7 @@ class MathjaxPlugin : DokkaPlugin() { 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 { +object MathjaxTransformer : PageTransformer { override fun invoke(input: RootPageNode) = input.transformContentPagesTree { it.modified( embeddedResources = it.embeddedResources + if (it.isNeedingMathjax) listOf(LIB_PATH) else emptyList() -- cgit From 16163f30353a6a17d3c038c5ec1f00c5b32f1f80 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Thu, 27 Feb 2020 10:50:48 +0100 Subject: Small adjustments to the new model --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index cded0929..1d62fd17 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -25,8 +25,8 @@ object MathjaxTransformer : PageTransformer { } private val ContentPage.isNeedingMathjax - get() = documentable?.platformInfo - ?.flatMap { it.documentationNode.children } + get() = documentable?.documentation?.values + ?.flatMap { it.children } .orEmpty() .any { (it as? CustomWrapperTag)?.name == ANNOTATION } } \ No newline at end of file -- cgit From cc89f0b74a870303c854fcb892d469d4c8fb17a8 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Tue, 9 Jun 2020 16:31:58 +0200 Subject: Gives text presentation for `SinceKotlin` and hides it from rendering. Hides `Deprecated`. #944 --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 1d62fd17..9e6ed965 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka.mathjax import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.model.doc.CustomWrapperTag +import org.jetbrains.dokka.model.doc.CustomTagWrapper import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaPlugin @@ -28,5 +28,5 @@ object MathjaxTransformer : PageTransformer { get() = documentable?.documentation?.values ?.flatMap { it.children } .orEmpty() - .any { (it as? CustomWrapperTag)?.name == ANNOTATION } + .any { (it as? CustomTagWrapper)?.name == ANNOTATION } } \ No newline at end of file -- cgit From 0c848be52c90cc1136d9ccbcd55b9a290bc7b58b Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Mon, 13 Jul 2020 19:41:03 -0700 Subject: Add a basic mathjax test --- .../mathjax/src/test/kotlin/MathjaxPluginTest.kt | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt b/plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt new file mode 100644 index 00000000..33269ce7 --- /dev/null +++ b/plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt @@ -0,0 +1,85 @@ +package mathjaxTest + +import org.jetbrains.dokka.mathjax.MathjaxPlugin +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.jsoup.Jsoup +import org.junit.jupiter.api.Test +import utils.TestOutputWriterPlugin + +class MathjaxPluginTest : AbstractCoreTest() { + @Test + fun basicMathjaxTest() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/kotlin/test/Test.kt") + } + } + } + val source = + """ + |/src/main/kotlin/test/Test.kt + |package example + | /** + | * {@usesMathJax} + | * + | *

\(\alpha_{out} = \alpha_{dst}\)

+ | *

\(C_{out} = C_{dst}\)

+ | */ + """.trimIndent() + val writerPlugin = TestOutputWriterPlugin() + testInline( + source, + configuration, + pluginOverrides = listOf(writerPlugin, MathjaxPlugin()) + ) { + renderingStage = { + _, _ -> Jsoup + .parse(writerPlugin.writer.contents["root/example.html"]) + .head() + .select("link, script") + .let { + val link = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" + assert(it.`is`("[href=$link], [src=$link]")) + } + } + } + } + + @Test + fun basicNoMathjaxTest() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/kotlin/test/Test.kt") + } + } + } + val source = + """ + |/src/main/kotlin/test/Test.kt + |package example + | /** + | *

\(\alpha_{out} = \alpha_{dst}\)

+ | *

\(C_{out} = C_{dst}\)

+ | */ + """.trimIndent() + val writerPlugin = TestOutputWriterPlugin() + testInline( + source, + configuration, + pluginOverrides = listOf(writerPlugin, MathjaxPlugin()) + ) { + renderingStage = { + _, _ -> Jsoup + .parse(writerPlugin.writer.contents["root/example.html"]) + .head() + .select("link, script") + .let { + val link = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" + assert(!it.`is`("[href=$link], [src=$link]")) + } + } + } + } +} -- cgit From c2b2f62dbce00e927214416cba33653048582443 Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Tue, 14 Jul 2020 09:16:40 -0700 Subject: Add fixes so the test actually passes --- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 2 +- .../mathjax/src/test/kotlin/MathjaxPluginTest.kt | 28 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'plugins/mathjax/src') diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 9e6ed965..63699585 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -15,7 +15,7 @@ class MathjaxPlugin : DokkaPlugin() { } 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" +internal const val LIB_PATH = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" object MathjaxTransformer : PageTransformer { override fun invoke(input: RootPageNode) = input.transformContentPagesTree { diff --git a/plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt b/plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt index 33269ce7..4a4ada23 100644 --- a/plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt +++ b/plugins/mathjax/src/test/kotlin/MathjaxPluginTest.kt @@ -1,5 +1,6 @@ package mathjaxTest +import org.jetbrains.dokka.mathjax.LIB_PATH import org.jetbrains.dokka.mathjax.MathjaxPlugin import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.jsoup.Jsoup @@ -8,7 +9,7 @@ import utils.TestOutputWriterPlugin class MathjaxPluginTest : AbstractCoreTest() { @Test - fun basicMathjaxTest() { + fun noMathjaxTest() { val configuration = dokkaConfiguration { sourceSets { sourceSet { @@ -21,11 +22,9 @@ class MathjaxPluginTest : AbstractCoreTest() { |/src/main/kotlin/test/Test.kt |package example | /** - | * {@usesMathJax} - | * - | *

\(\alpha_{out} = \alpha_{dst}\)

- | *

\(C_{out} = C_{dst}\)

+ | * Just a regular kdoc | */ + | fun test(): String = "" """.trimIndent() val writerPlugin = TestOutputWriterPlugin() testInline( @@ -35,19 +34,18 @@ class MathjaxPluginTest : AbstractCoreTest() { ) { renderingStage = { _, _ -> Jsoup - .parse(writerPlugin.writer.contents["root/example.html"]) + .parse(writerPlugin.writer.contents["root/example/test.html"]) .head() .select("link, script") .let { - val link = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" - assert(it.`is`("[href=$link], [src=$link]")) + assert(!it.`is`("[href=$LIB_PATH], [src=$LIB_PATH]")) } } } } @Test - fun basicNoMathjaxTest() { + fun usingMathjaxTest() { val configuration = dokkaConfiguration { sourceSets { sourceSet { @@ -60,9 +58,12 @@ class MathjaxPluginTest : AbstractCoreTest() { |/src/main/kotlin/test/Test.kt |package example | /** - | *

\(\alpha_{out} = \alpha_{dst}\)

- | *

\(C_{out} = C_{dst}\)

+ | * @usesMathJax + | * + | * \(\alpha_{out} = \alpha_{dst}\) + | * \(C_{out} = C_{dst}\) | */ + | fun test(): String = "" """.trimIndent() val writerPlugin = TestOutputWriterPlugin() testInline( @@ -72,12 +73,11 @@ class MathjaxPluginTest : AbstractCoreTest() { ) { renderingStage = { _, _ -> Jsoup - .parse(writerPlugin.writer.contents["root/example.html"]) + .parse(writerPlugin.writer.contents["root/example/test.html"]) .head() .select("link, script") .let { - val link = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" - assert(!it.`is`("[href=$link], [src=$link]")) + assert(it.`is`("[href=$LIB_PATH], [src=$LIB_PATH]")) } } } -- cgit