From acd9234be6909a69f89600e9c8ddde642d36b1cf Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Wed, 14 Apr 2021 15:16:27 +0200 Subject: Fix visibility on enum entry property (#1828) --- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 2 +- .../src/test/kotlin/filter/VisibilityFilterTest.kt | 81 ++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) (limited to 'plugins/base/src/test') diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index eb35085e..2535140c 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -115,7 +115,7 @@ class EnumsTest : BaseAbstractTest() { m.packages.let { p -> p.first().classlikes.let { c -> val enum = c.first() as DEnum - val (first, second) = enum.entries + val (first, second) = enum.entries.sortedBy { it.name } assertEquals(1, first.extra.allOfType().size) assertEquals(1, second.extra.allOfType().size) diff --git a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt index 416db52b..ffefaaea 100644 --- a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt +++ b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt @@ -2,9 +2,12 @@ package filter import org.jetbrains.dokka.PackageOptionsImpl import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.model.DEnum import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue class VisibilityFilterTest : BaseAbstractTest() { @@ -206,4 +209,82 @@ class VisibilityFilterTest : BaseAbstractTest() { } } } + + @Test + fun `internal property from enum should be skipped`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + includeNonPublic = false + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + |enum class Test(internal val value: Int) { + | A(0) { + | override fun testFun(): Float = 0.05F + | }, + | B(1) { + | override fun testFun(): Float = 0.1F + | }; + | + | internal open fun testFun(): Float = 0.5F + |} + """.trimMargin(), + configuration + ) { + documentablesTransformationStage = { module -> + val enum = module.packages.flatMap { it.classlikes }.filterIsInstance().first() + val entry = enum.entries.first() + + assertFalse("testFun" in entry.functions.map { it.name }) + assertFalse("value" in entry.properties.map { it.name }) + assertFalse("testFun" in enum.functions.map { it.name }) + } + } + } + + @Test + fun `internal property from enum`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + includeNonPublic = true + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + |enum class Test(internal val value: Int) { + | A(0) { + | override fun testFun(): Float = 0.05F + | }, + | B(1) { + | override fun testFun(): Float = 0.1F + | }; + | + | internal open fun testFun(): Float = 0.5F + |} + """.trimMargin(), + configuration + ) { + documentablesTransformationStage = { module -> + val enum = module.packages.flatMap { it.classlikes }.filterIsInstance().first() + val entry = enum.entries.first() + + assertTrue("testFun" in entry.functions.map { it.name }) + assertTrue("value" in entry.properties.map { it.name }) + assertTrue("testFun" in enum.functions.map { it.name }) + } + } + } } -- cgit