diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-03-01 11:57:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 11:57:59 +0100 |
commit | 32fc2899cbe08e4e30326128e0f642ac4e08a342 (patch) | |
tree | 66bbd6784f9d2f3dac7b7467f5b5d9aec2dd5f3a /plugins/base/src/test/kotlin | |
parent | c01e49eec9558736959d12820361624a3c3e41e5 (diff) | |
download | dokka-32fc2899cbe08e4e30326128e0f642ac4e08a342.tar.gz dokka-32fc2899cbe08e4e30326128e0f642ac4e08a342.tar.bz2 dokka-32fc2899cbe08e4e30326128e0f642ac4e08a342.zip |
Bump markdown to 0.2.0 and fix negation in links being interpreted as img (#1754)
* Bump markdown library to 0.2.0
* Render shorthand images as link with text
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r-- | plugins/base/src/test/kotlin/markdown/LinkTest.kt | 133 |
1 files changed, 127 insertions, 6 deletions
diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt index 2bcc0bf0..186fe9ee 100644 --- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt +++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt @@ -6,7 +6,8 @@ import org.jetbrains.dokka.pages.ClasslikePageNode import org.jetbrains.dokka.pages.ContentDRILink import org.jetbrains.dokka.pages.MemberPageNode import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest -import org.jetbrains.dokka.model.doc.DocumentationLink +import org.jetbrains.dokka.links.* +import org.jetbrains.dokka.model.doc.* import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test @@ -39,7 +40,8 @@ class LinkTest : BaseAbstractTest() { .content .dfs { node -> node is ContentDRILink && - node.address.toString() == "parser//test/#java.lang.ClassLoader/PointingToDeclaration/"} + node.address.toString() == "parser//test/#java.lang.ClassLoader/PointingToDeclaration/" + } ) } } @@ -75,7 +77,7 @@ class LinkTest : BaseAbstractTest() { val destinationDri = (root.documentable as WithGenerics).generics.first().dri.toString() assertEquals(destinationDri, "/Outer///PointingToGenericParameters(0)/") - assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == destinationDri } ) + assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == destinationDri }) } } } @@ -91,7 +93,7 @@ class LinkTest : BaseAbstractTest() { } testInline( - """ + """ |/src/main/kotlin/Test.kt |package example | @@ -101,14 +103,133 @@ class LinkTest : BaseAbstractTest() { |fun stop(hammerTime: String, waitAMinute: String) {} | """.trimMargin(), - configuration + configuration ) { documentablesMergingStage = { module -> val parameter = module.dfs { it.name == "waitAMinute" } - val link = module.dfs { it.name == "stop" }!!.documentation.values.single().dfs { it is DocumentationLink } as DocumentationLink + val link = module.dfs { it.name == "stop" }!!.documentation.values.single() + .dfs { it is DocumentationLink } as DocumentationLink assertEquals(parameter!!.dri, link.dri) } } } + + @Test + fun `link with exclamation mark`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/Test.kt + |package example + | + |/** + |* Link to ![waitAMinute] + |*/ + |fun stop(hammerTime: String, waitAMinute: String) {} + | + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val functionDocs = module.packages.flatMap { it.functions }.first().documentation.values.first() + val expected = Description( + root = CustomDocTag( + children = listOf( + P( + children = listOf( + Text("Link to !"), + DocumentationLink( + dri = DRI( + packageName = "example", + callable = Callable( + "stop", + receiver = null, + params = listOf( + TypeConstructor("kotlin.String", emptyList()), + TypeConstructor("kotlin.String", emptyList()) + ) + ), + target = PointingToCallableParameters(1) + ), + children = listOf( + Text("waitAMinute") + ), + params = mapOf("href" to "[waitAMinute]") + ) + ) + ) + ), + name = "MARKDOWN_FILE" + ) + ) + + assertEquals(expected, functionDocs.children.first()) + } + } + } + + @Test + fun `link to property with exclamation mark`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/Testing.kt + |package example + | + |/** + |* Link to ![Testing.property] + |*/ + |class Testing { + | var property = "" + |} + | + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val functionDocs = module.packages.flatMap { it.classlikes }.first().documentation.values.first() + val expected = Description( + root = CustomDocTag( + children = listOf( + P( + children = listOf( + Text("Link to !"), + DocumentationLink( + dri = DRI( + packageName = "example", + classNames = "Testing", + callable = Callable("property", null, emptyList()), + target = PointingToDeclaration + ), + children = listOf( + Text("Testing.property") + ), + params = mapOf("href" to "[Testing.property]") + ) + ) + ) + ), + name = "MARKDOWN_FILE" + ) + ) + + assertEquals(expected, functionDocs.children.first()) + } + } + } } |