From bfd41ce2a0d43419a671961c19b7d755cffdcfc8 Mon Sep 17 00:00:00 2001
From: Ignat Beresnev <ignat@beresnev.me>
Date: Thu, 23 Dec 2021 14:32:18 +0300
Subject: Introduce documentedVisibilities setting (#2270)

* Introduce `documentedVisibilities` setting

* Remove hardcoded doc generation for Visibility.PUBLIC, correct tests

* Add maven, gradle and cli integration tests for documentedVisibilities

* Fix maven plugin configuration overriding the default value

* Remove test debug prints

* Correct an inconsistency with default values and leave a comment of intentions

* Add a test for visibility of private setter
---
 .../jetbrains/dokka/it/cli/CliIntegrationTest.kt   | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)

(limited to 'integration-tests/cli/src/integrationTest/kotlin/org/jetbrains')

diff --git a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
index 8935f8f5..b87badd7 100644
--- a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
+++ b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
@@ -84,6 +84,14 @@ class CliIntegrationTest : AbstractCliIntegrationTest() {
             assertNoEmptySpans(file)
         }
 
+        assertContentVisibility(
+            contentFiles = projectDir.allHtmlFiles().toList(),
+            documentPublic = true,
+            documentInternal = false,
+            documentProtected = false,
+            documentPrivate = false
+        )
+
         assertFalse(
             projectDir.resolve("output").resolve("index.html").readText().contains("emptypackagetest"),
             "Expected not to render empty packages"
@@ -205,4 +213,50 @@ class CliIntegrationTest : AbstractCliIntegrationTest() {
         assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)")
         assertFalse(result.output.contains("Loaded plugins: "), "Expected output to not contain info logs")
     }
+
+    @Test
+    fun `custom documented visibility`() {
+        val dokkaOutputDir = File(projectDir, "output")
+        assertTrue(dokkaOutputDir.mkdirs())
+        val process = ProcessBuilder(
+            "java", "-jar", cliJarFile.path,
+            "-outputDir", dokkaOutputDir.path,
+            "-pluginsClasspath", basePluginJarFile.path,
+            "-moduleName", "Basic Project",
+            "-sourceSet",
+            buildString {
+                append(" -sourceSetName cliMain")
+                append(" -src ${File(projectDir, "src").path}")
+                append(" -jdkVersion 8")
+                append(" -analysisPlatform jvm")
+                append(" -documentedVisibilities PUBLIC;PROTECTED")
+                append(" -perPackageOptions it.overriddenVisibility.*,+visibility:PRIVATE")
+            }
+        )
+            .redirectErrorStream(true)
+            .start()
+
+        val result = process.awaitProcessResult()
+        assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)")
+
+        val allHtmlFiles = projectDir.allHtmlFiles().toList()
+
+        assertContentVisibility(
+            contentFiles = allHtmlFiles,
+            documentPublic = true,
+            documentProtected = true, // sourceSet documentedVisibilities
+            documentInternal = false,
+            documentPrivate = true // for overriddenVisibility package
+        )
+
+        assertContainsFilePaths(
+            outputFiles = allHtmlFiles,
+            expectedFilePaths = listOf(
+                // documentedVisibilities is overridden for package `overriddenVisibility` specifically
+                // to include private code, so html pages for it are expected to have been created
+                Regex("it\\.overriddenVisibility/-visible-private-class/private-method\\.html"),
+                Regex("it\\.overriddenVisibility/-visible-private-class/private-val\\.html"),
+            )
+        )
+    }
 }
-- 
cgit