From fff8bb5ffe629bebd2d5e071dd12966a7d89f885 Mon Sep 17 00:00:00 2001 From: Filip ZybaƂa Date: Thu, 14 May 2020 10:17:25 +0200 Subject: Added deprecation filter. Included some tests. --- .../content/signatures/ContentForSignaturesTest.kt | 1 + .../test/kotlin/filter/DeprecationFilterTest.kt | 173 +++++++++++++++++++++ .../test/kotlin/filter/EmptyPackagesFilterTest.kt | 64 ++++++++ .../src/test/kotlin/filter/VisibilityFilterTest.kt | 173 +++++++++++++++++++++ .../test/kotlin/visibility/VisibilityFilterTest.kt | 173 --------------------- 5 files changed, 411 insertions(+), 173 deletions(-) create mode 100644 plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt create mode 100644 plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt create mode 100644 plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt delete mode 100644 plugins/base/src/test/kotlin/visibility/VisibilityFilterTest.kt (limited to 'plugins/base/src/test/kotlin') diff --git a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt index dc0488c8..20aba2e8 100644 --- a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt +++ b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt @@ -16,6 +16,7 @@ class ContentForSignaturesTest : AbstractCoreTest() { pass { sourceRoots = listOf("src/") analysisPlatform = "jvm" + includeNonPublic = true } } } diff --git a/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt new file mode 100644 index 00000000..c15e53e8 --- /dev/null +++ b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt @@ -0,0 +1,173 @@ +package filter + +import org.jetbrains.dokka.PackageOptionsImpl +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class DeprecationFilterTest : AbstractCoreTest() { + @Test + fun `function with false global skipDeprecated`() { + val configuration = dokkaConfiguration { + passes { + pass { + skipDeprecated = false + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |fun testFunction() { } + | + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 1 + ) + } + } + } + @Test + fun `deprecated function with false global skipDeprecated`() { + val configuration = dokkaConfiguration { + passes { + pass { + skipDeprecated = false + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |@Deprecated("dep") + |fun testFunction() { } + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 1 + ) + } + } + } + @Test + fun `deprecated function with true global skipDeprecated`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + skipDeprecated = true + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |@Deprecated("dep") + |fun testFunction() { } + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 0 + ) + } + } + } + @Test + fun `deprecated function with false global true package skipDeprecated`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + skipDeprecated = false + perPackageOptions = mutableListOf( + PackageOptionsImpl("example", + true, + false, + true, + false) + ) + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |@Deprecated("dep") + |fun testFunction() { } + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 0 + ) + } + } + } + @Test + fun `deprecated function with true global false package skipDeprecated`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + skipDeprecated = true + perPackageOptions = mutableListOf( + PackageOptionsImpl("example", + false, + false, + false, + false) + ) + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |@Deprecated("dep") + |fun testFunction() { } + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 1 + ) + } + } + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt b/plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt new file mode 100644 index 00000000..7d96541b --- /dev/null +++ b/plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt @@ -0,0 +1,64 @@ +package filter + +import org.jetbrains.dokka.PackageOptionsImpl +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class EmptyPackagesFilterTest : AbstractCoreTest() { + @Test + fun `empty package with false skipEmptyPackages`() { + val configuration = dokkaConfiguration { + passes { + pass { + skipEmptyPackages = false + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.isNotEmpty() + ) + } + } + } + @Test + fun `empty package with true skipEmptyPackages`() { + val configuration = dokkaConfiguration { + passes { + pass { + skipEmptyPackages = true + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.isEmpty() + ) + } + } + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt new file mode 100644 index 00000000..5e8e33dc --- /dev/null +++ b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt @@ -0,0 +1,173 @@ +package filter + +import org.jetbrains.dokka.PackageOptionsImpl +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class VisibilityFilterTest : AbstractCoreTest() { + @Test + fun `public function with false global includeNonPublic`() { + val configuration = dokkaConfiguration { + passes { + pass { + includeNonPublic = false + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |fun testFunction() { } + | + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 1 + ) + } + } + } + @Test + fun `private function with false global includeNonPublic`() { + val configuration = dokkaConfiguration { + passes { + pass { + includeNonPublic = false + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |private fun testFunction() { } + | + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 0 + ) + } + } + } + @Test + fun `private function with true global includeNonPublic`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + includeNonPublic = true + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |private fun testFunction() { } + | + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 1 + ) + } + } + } + @Test + fun `private function with false global true package includeNonPublic`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + includeNonPublic = false + perPackageOptions = mutableListOf( + PackageOptionsImpl("example", + true, + false, + false, + false) + ) + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |private fun testFunction() { } + | + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 1 + ) + } + } + } + @Test + fun `private function with true global false package includeNonPublic`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + includeNonPublic = true + perPackageOptions = mutableListOf( + PackageOptionsImpl("example", + false, + false, + false, + false) + ) + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package example + | + |private fun testFunction() { } + | + | + | + """.trimMargin(), + configuration + ) { + documentablesFirstTransformationStep = { + Assertions.assertTrue( + it.component2().packages.first().functions.size == 0 + ) + } + } + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/visibility/VisibilityFilterTest.kt b/plugins/base/src/test/kotlin/visibility/VisibilityFilterTest.kt deleted file mode 100644 index 1ce567c6..00000000 --- a/plugins/base/src/test/kotlin/visibility/VisibilityFilterTest.kt +++ /dev/null @@ -1,173 +0,0 @@ -package visibility - -import org.jetbrains.dokka.PackageOptionsImpl -import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -class VisibilityFilterTest : AbstractCoreTest() { - @Test - fun `public function with false global includeNonPublic`() { - val configuration = dokkaConfiguration { - passes { - pass { - includeNonPublic = false - sourceRoots = listOf("src/main/kotlin/basic/Test.kt") - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package example - | - |fun testFunction() { } - | - | - | - """.trimMargin(), - configuration - ) { - documentablesFirstTransformationStep = { - Assertions.assertTrue( - it.component2().packages.first().functions.size == 1 - ) - } - } - } - @Test - fun `private function with false global includeNonPublic`() { - val configuration = dokkaConfiguration { - passes { - pass { - includeNonPublic = false - sourceRoots = listOf("src/main/kotlin/basic/Test.kt") - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package example - | - |private fun testFunction() { } - | - | - | - """.trimMargin(), - configuration - ) { - documentablesFirstTransformationStep = { - Assertions.assertTrue( - it.component2().packages.isEmpty() - ) - } - } - } - @Test - fun `private function with true global includeNonPublic`() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/basic/Test.kt") - includeNonPublic = true - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package example - | - |private fun testFunction() { } - | - | - | - """.trimMargin(), - configuration - ) { - documentablesFirstTransformationStep = { - Assertions.assertTrue( - it.component2().packages.first().functions.size == 1 - ) - } - } - } - @Test - fun `private function with false global true package includeNonPublic`() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/basic/Test.kt") - includeNonPublic = false - perPackageOptions = mutableListOf( - PackageOptionsImpl("example", - true, - false, - false, - false) - ) - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package example - | - |private fun testFunction() { } - | - | - | - """.trimMargin(), - configuration - ) { - documentablesFirstTransformationStep = { - Assertions.assertTrue( - it.component2().packages.first().functions.size == 1 - ) - } - } - } - @Test - fun `private function with true global false package includeNonPublic`() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/basic/Test.kt") - includeNonPublic = true - perPackageOptions = mutableListOf( - PackageOptionsImpl("example", - false, - false, - false, - false) - ) - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package example - | - |private fun testFunction() { } - | - | - | - """.trimMargin(), - configuration - ) { - documentablesFirstTransformationStep = { - Assertions.assertTrue( - it.component2().packages.isEmpty() - ) - } - } - } -} \ No newline at end of file -- cgit