From 69b8591126833cf1437611972c7407702a1c986a Mon Sep 17 00:00:00 2001 From: Filip ZybaƂa Date: Thu, 2 Apr 2020 12:54:19 +0200 Subject: Modified MarkdownParser to fit new See structure. Fixed minor errors in tests. --- .../content/seealso/ContentForSeeAlsoTest.kt | 324 +++++++++++++++++++++ 1 file changed, 324 insertions(+) create mode 100644 plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt (limited to 'plugins/base/src/test/kotlin/content/seealso') diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt new file mode 100644 index 00000000..ae53a848 --- /dev/null +++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt @@ -0,0 +1,324 @@ +package content.seealso +import matchers.content.* +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Test +import utils.pWrapped +import utils.signature +import utils.unnamedTag + +class ContentForSeeAlsoTest : AbstractCoreTest() { + private val testConfiguration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + analysisPlatform = "jvm" + targets = listOf("jvm") + } + } + } + + @Test + fun `undocumented function`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + } + } + } + } + + @Test + fun `undocumented seealso`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | /** + | * @see abc + | */ + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link{ +"abc" } + group { } + } + } + } + } + } + } + } + + @Test + fun `documented seealso`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | /** + | * @see abc Comment to abc + | */ + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link{ +"abc" } + group { +"Comment to abc" } + } + } + } + } + } + } + } + + @Test + fun `undocumented seealso with stdlib link`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | /** + | * @see Collection + | */ + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "kotlin.collections/Collection////" + link{ +"Collection"} + group { } + } + } + } + } + } + } + } + + @Test + fun `documented seealso with stdlib link`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | /** + | * @see Collection Comment to stdliblink + | */ + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link{ +"Collection" } + group { +"Comment to stdliblink" } + } + } + } + } + } + } + } + + @Test + fun `documented seealso with stdlib link with other tags`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | /** + | * random comment + | * @see Collection Comment to stdliblink + | * @author pikinier20 + | * @since 0.11 + | */ + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + header(3) { +"Description" } + platformHinted { + pWrapped("random comment") + unnamedTag("Author") { +"pikinier20" } + unnamedTag("Since") { +"0.11" } + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link{ +"Collection" } + group { +"Comment to stdliblink" } + } + } + } + } + } + } + } + + @Test + fun `documented multiple see also`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | /** + | * @see abc Comment to abc1 + | * @see abc Comment to abc2 + | */ + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link{ +"abc" } + group { +"Comment to abc2" } + } + } + } + } + } + } + } + + @Test + fun `documented multiple see also mixed source`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | /** + | * @see abc Comment to abc1 + | * @see[Collection] Comment to collection + | */ + |fun function(abc: String) { + | println(abc) + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + signature("function", null, "abc" to "String") + } + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link{ +"abc" } + group { +"Comment to abc1" } + } + group { + //DRI should be "test//abc/#/-1/" + link{ +"Collection" } + group { +"Comment to collection" } + } + } + } + } + } + } + } +} \ No newline at end of file -- cgit