diff options
author | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2021-12-23 17:43:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-23 19:43:13 +0300 |
commit | 1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c (patch) | |
tree | c3fe4839a2e876a0c572cfc75d71e204f356bd16 /plugins/base/src/test | |
parent | bfd41ce2a0d43419a671961c19b7d755cffdcfc8 (diff) | |
download | dokka-1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c.tar.gz dokka-1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c.tar.bz2 dokka-1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c.zip |
Remove filtering out primary constructors from constructors tab (#2277)
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r-- | plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt | 12 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt | 42 |
2 files changed, 51 insertions, 3 deletions
diff --git a/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt index 92bba3c6..12160db8 100644 --- a/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt +++ b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt @@ -4,6 +4,7 @@ import matchers.content.* import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.junit.jupiter.api.Test +import utils.ParamAttributes import utils.functionSignature class ConstructorsSignaturesTest : BaseAbstractTest() { @@ -183,6 +184,17 @@ class ConstructorsSignaturesTest : BaseAbstractTest() { name = "SomeClass" ) } + group { + link { +"SomeClass" } + functionSignature( + annotations = emptyMap(), + visibility = "", + modifier = "", + keywords = emptySet(), + name = "SomeClass", + params = listOf("a" to ParamAttributes(emptyMap(), emptySet(), "String")).toTypedArray() + ) + } } skipAllNotMatching() } diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt index e17f0800..a6f9af7d 100644 --- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt +++ b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt @@ -1,9 +1,7 @@ package transformerBuilders; import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.pages.RendererSpecificResourcePage -import org.jetbrains.dokka.pages.RenderingStrategy +import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jetbrains.dokka.transformers.pages.PageTransformer @@ -11,6 +9,7 @@ import org.jetbrains.dokka.transformers.pages.pageMapper import org.jetbrains.dokka.transformers.pages.pageScanner import org.jetbrains.dokka.transformers.pages.pageStructureTransformer import org.junit.jupiter.api.Test +import kotlin.test.assertEquals class PageTransformerBuilderTest : BaseAbstractTest() { @@ -133,6 +132,43 @@ class PageTransformerBuilderTest : BaseAbstractTest() { } } + @Test + fun `kotlin constructors tab should exist even though there is primary constructor only`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + testInline( + """ + |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt + |package kotlinAsJavaPlugin + | + |class Test(val xd: Int) + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { root -> + val content = root.children + .flatMap { it.children<ContentPage>() } + .map { it.content }.single().children + .filterIsInstance<ContentGroup>() + .single { it.dci.kind == ContentKind.Main }.children + + val constructorTabsCount = content.filter { it is ContentHeader }.flatMap { + it.children.filter { it is ContentText } + }.count { + (it as? ContentText)?.text == "Constructors" + } + + assertEquals(1, constructorTabsCount) + } + } + } + + private fun <T> Collection<T>.assertCount(n: Int, prefix: String = "") = assert(count() == n) { "${prefix}Expected $n, got ${count()}" } |