diff options
author | Marcin Aman <maman@virtuslab.com> | 2020-05-20 17:58:31 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-05-20 18:13:23 +0200 |
commit | 091294c5a920521df1b4bf61c2492b78f3559321 (patch) | |
tree | f00833367aca8f8bfdd6ec77495a40576e30d78e /plugins | |
parent | 885bf34ac6d9b9a5974cab35d9dd5a224b0ccc4c (diff) | |
download | dokka-091294c5a920521df1b4bf61c2492b78f3559321.tar.gz dokka-091294c5a920521df1b4bf61c2492b78f3559321.tar.bz2 dokka-091294c5a920521df1b4bf61c2492b78f3559321.zip |
Tabs for sections - update tests
Diffstat (limited to 'plugins')
6 files changed, 266 insertions, 219 deletions
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 409b0d6f..847e9667 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -202,7 +202,7 @@ open class DefaultPageCreator( protected open fun contentForDescription( d: Documentable - ): ContentNode { + ): List<ContentNode> { val tags: GroupedTags = d.documentation.flatMap { (pd, doc) -> doc.children.asSequence().map { pd to it }.toList() }.groupBy { it.second::class } @@ -224,17 +224,19 @@ open class DefaultPageCreator( val unnamedTags: List<SourceSetDependent<TagWrapper>> = tags.filterNot { (k, _) -> k.isSubclassOf(NamedTagWrapper::class) || k in specialTags } .map { (_, v) -> v.mapNotNull { (k,v) -> k?.let { it to v } }.toMap() } - platforms.forEach { platform -> - unnamedTags.forEach { pdTag -> - pdTag[platform]?.also { tag -> - group(sourceSets = setOf(platform)) { - header(4, tag.toHeaderString()) - comment(tag.root) + if(unnamedTags.isNotEmpty()){ + platforms.forEach { platform -> + unnamedTags.forEach { pdTag -> + pdTag[platform]?.also { tag -> + group(sourceSets = setOf(platform)) { + header(4, tag.toHeaderString()) + comment(tag.root) + } } } } } - } + }.children } protected open fun contentForComments( diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt index fbed41fc..15f70eae 100644 --- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt +++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt @@ -33,7 +33,9 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { @@ -64,17 +66,16 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - } + pWrapped("comment to function") } } } @@ -102,18 +103,17 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - unnamedTag("Author") { +"Kordyjan" } - unnamedTag("Since") { +"0.11" } - } + unnamedTag("Author") { +"Kordyjan" } + unnamedTag("Since") { +"0.11" } } } } @@ -142,19 +142,18 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - unnamedTag("Author") { +"Kordyjan" } - unnamedTag("Since") { +"0.11" } - } + pWrapped("comment to function") + unnamedTag("Author") { +"Kordyjan" } + unnamedTag("Since") { +"0.11" } } } } @@ -182,21 +181,24 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"abc" - group { +"comment to param" } + pWrapped("comment to function") + header(2) { +"Parameters" } + group { + platformHinted { + table { + group { + +"abc" + group { +"comment to param" } + } } } } @@ -229,7 +231,9 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { @@ -242,22 +246,23 @@ class ContentForParamsTest : AbstractCoreTest() { ) } after { - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } - } - group { - +"second" - group { +"comment to second param" } - } - group { - +"third" - group { +"comment to third param" } + pWrapped("comment to function") + header(2) { +"Parameters" } + group { + platformHinted { + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"second" + group { +"comment to second param" } + } + group { + +"third" + group { +"comment to third param" } + } } } } @@ -289,7 +294,9 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { @@ -302,21 +309,22 @@ class ContentForParamsTest : AbstractCoreTest() { ) } after { - header(3) { +"Description" } - platformHinted { - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } - } - group { - +"second" - group { +"comment to second param" } - } - group { - +"third" - group { +"comment to third param" } + header(2) { +"Parameters" } + group { + platformHinted { + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"second" + group { +"comment to second param" } + } + group { + +"third" + group { +"comment to third param" } + } } } } @@ -348,25 +356,28 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignatureWithReceiver("String", "function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"<receiver>" - group { +"comment to receiver" } - } - group { - +"abc" - group { +"comment to param" } + pWrapped("comment to function") + header(2) { +"Parameters" } + group { + platformHinted { + table { + group { + +"<receiver>" + group { +"comment to receiver" } + } + group { + +"abc" + group { +"comment to param" } + } } } } @@ -398,7 +409,9 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { @@ -411,18 +424,19 @@ class ContentForParamsTest : AbstractCoreTest() { ) } after { - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } - } - group { - +"third" - group { +"comment to third param" } + pWrapped("comment to function") + header(2) { +"Parameters" } + group { + platformHinted { + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"third" + group { +"comment to third param" } + } } } } @@ -457,7 +471,9 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { @@ -470,26 +486,28 @@ class ContentForParamsTest : AbstractCoreTest() { ) } after { - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } - } - group { - +"second" - group { +"comment to second param" } - } - group { - +"third" - group { +"comment to third param" } + pWrapped("comment to function") + unnamedTag("Author") { +"Kordyjan" } + unnamedTag("Since") { +"0.11" } + header(2) { +"Parameters" } + + group { + platformHinted { + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"second" + group { +"comment to second param" } + } + group { + +"third" + group { +"comment to third param" } + } } } - unnamedTag("Author") { +"Kordyjan" } - unnamedTag("Since") { +"0.11" } } } } diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt index 8121543d..b5cb3b72 100644 --- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt +++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt @@ -35,7 +35,9 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group{ + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { @@ -66,21 +68,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link { +"abc" } - group { } + header(2) { +"See also" } + group { + platformHinted { + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"abc" } + group { } + } } } } @@ -110,21 +115,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link { +"abc" } - group { +"Comment to abc" } + header(2) { +"See also" } + group { + platformHinted { + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"abc" } + group { +"Comment to abc" } + } } } } @@ -154,21 +162,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "kotlin.collections/Collection////" - link { +"Collection" } - group { } + header(2) { +"See also" } + group { + platformHinted { + table { + group { + //DRI should be "kotlin.collections/Collection////" + link { +"Collection" } + group { } + } } } } @@ -198,25 +209,27 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link { +"Collection" } - group { +"Comment to stdliblink" } + header(2) { +"See also" } + group { + platformHinted { + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"Collection" } + group { +"Comment to stdliblink" } + } } } } - } } } @@ -246,24 +259,28 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - 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" } + pWrapped("random comment") + unnamedTag("Author") { +"pikinier20" } + unnamedTag("Since") { +"0.11" } + + header(2) { +"See also" } + group { + platformHinted { + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"Collection" } + group { +"Comment to stdliblink" } + } } } } @@ -294,21 +311,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link { +"abc" } - group { +"Comment to abc2" } + header(2) { +"See also" } + group { + platformHinted { + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"abc" } + group { +"Comment to abc2" } + } } } } @@ -339,26 +359,29 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - header(1) { +"function" } + group { + header(1) { +"function" } + } divergentGroup { divergentInstance { divergent { bareSignature("function", null, "abc" to "String") } after { - 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" } + header(2) { +"See also" } + group { + platformHinted { + 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" } + } } } } diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt index e7883bc1..b18c3a5a 100644 --- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt +++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt @@ -112,8 +112,8 @@ class LinkableContentTest : AbstractCoreTest() { packageChildren.forEach { val name = it.name.substringBefore("Class") val crl = it.safeAs<ClasslikePageNode>()?.content?.safeAs<ContentGroup>()?.children?.last() - ?.safeAs<ContentGroup>()?.children?.last()?.safeAs<ContentTable>()?.children?.singleOrNull() - ?.safeAs<ContentGroup>()?.children?.singleOrNull()?.safeAs<ContentResolvedLink>() + ?.safeAs<ContentGroup>()?.children?.last()?.safeAs<ContentGroup>()?.children?.lastOrNull() + ?.safeAs<ContentTable>()?.children?.singleOrNull()?.safeAs<ContentGroup>()?.children?.singleOrNull().safeAs<ContentResolvedLink>() Assertions.assertEquals( "https://github.com/user/repo/tree/master/src/${name.toLowerCase()}Main/kotlin/${name}Class.kt#L3", crl?.address @@ -166,8 +166,11 @@ class LinkableContentTest : AbstractCoreTest() { .cast<ContentDivergentGroup>().children.single() .cast<ContentDivergentInstance>().after .cast<ContentGroup>().children.last() + .cast<ContentGroup>().children.last() .cast<PlatformHintedContent>().children.single() - .cast<ContentGroup>().children.single().cast<ContentGroup>().children.last() + .cast<ContentGroup>().children.single() + .cast<ContentTable>().children.single() + .cast<ContentGroup>().children.single() .cast<ContentGroup>().children.single() .cast<ContentCode>().children.single().cast<ContentText>().text Assertions.assertEquals( diff --git a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt index 1f310502..54bac755 100644 --- a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt @@ -30,7 +30,7 @@ class DivergentTest : RenderingOnlyTestBase() { } } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div(Div("a")))) + renderedContent.match(Div(Div(Div(Div("a"))))) } @Test @@ -45,7 +45,7 @@ class DivergentTest : RenderingOnlyTestBase() { } } HtmlRenderer(context).render(page) - renderedContent.match(Div("a")) + renderedContent.match(Div(Div("a"))) } @Test @@ -71,7 +71,7 @@ class DivergentTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div(Div("a"), Div("b"), Div("c")))) + renderedContent.match(Div(Div(Div(Div("a"), Div("b"), Div("c"))))) } @Test @@ -97,7 +97,7 @@ class DivergentTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div(Div("abc")))) + renderedContent.match(Div(Div((Div(Div("abc")))))) } @Test @@ -133,7 +133,7 @@ class DivergentTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div(Div("ae"), Div("bd"), Div("c")))) + renderedContent.match(Div(Div(Div(Div("ae"), Div("bd"), Div("c"))))) } @Test @@ -182,13 +182,10 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( - Div(Div(Div("a")), Div(Div())), - "a+", - Div(Div(Div("bd")), Div(Div())), - "bd+", - Div(Div(Div("c")), Div(Div())), - Div(Div(Div("e")), Div(Div())), - "e+" + Div(Div(Div(Div("a")), Div(Div())), "a+",), + Div(Div(Div(Div("bd")), Div(Div())), "bd+"), + Div(Div(Div(Div("c")), Div(Div()))), + Div(Div(Div(Div("e")), Div(Div())), "e+") ) } @@ -217,8 +214,10 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( - "ab-", - Div(Div(Div("ab"))) + Div( + "ab-", + Div(Div(Div("ab"))) + ) ) } @@ -247,8 +246,10 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( - Div(Div(Div("ab"))), - "ab+" + Div( + Div(Div(Div("ab"))), + "ab+" + ) ) } @@ -282,10 +283,13 @@ class DivergentTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) + val r = renderedContent renderedContent.match( - "ab-", - Div(Div(Div("ab"))), - "ab+" + Div( + "ab-", + Div(Div(Div("ab"))), + "ab+" + ) ) } @@ -320,11 +324,8 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( - "a-", - Div(Div(Div("a")), Div(Div("NATIVE"))), - "ab+b-", - Div(Div(Div("b")), Div(Div("NATIVE"))), - "ab+" + Div("a-", Div(Div(Div("a")), Div(Div("NATIVE"))), "ab+"), + Div("b-", Div(Div(Div("b")), Div(Div("NATIVE"))), "ab+") ) } }
\ No newline at end of file diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt index 968ab65a..db87051b 100644 --- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt +++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt @@ -2,12 +2,12 @@ package kotlinAsJavaPlugin import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.jetbrains.kotlin.utils.addToStdlib.cast +import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.junit.jupiter.api.Test class KotlinAsJavaPluginTest : AbstractCoreTest() { - fun fail(msg: String) = assert(false) { msg } - @Test fun topLevelTest() { val configuration = dokkaConfiguration { @@ -37,8 +37,8 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() { pagesGenerationStage = { root -> val content = (root.children.single().children.first { it.name == "TestKt" } as ContentPage).content - val children = content.mainContents - .filterIsInstance<ContentTable>() + val children = content.mainContents.first().cast<ContentGroup>() + .children.filterIsInstance<ContentTable>() .filter { it.children.isNotEmpty() } children.assertCount(2) @@ -77,7 +77,7 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() { .map { it.content } val children = contentList.flatMap { content -> - content.mainContents + content.mainContents.first().cast<ContentGroup>().children .filterIsInstance<ContentTable>() .filter { it.children.isNotEmpty() } }.filterNot { it.toString().contains("<init>") } |