diff options
author | Ignat Beresnev <ignat@beresnev.me> | 2021-12-23 14:32:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-23 14:32:18 +0300 |
commit | bfd41ce2a0d43419a671961c19b7d755cffdcfc8 (patch) | |
tree | 00d1fcd75ff7c25de20c8b0621e3bfb11cd3f61a /integration-tests/src/main/kotlin/org/jetbrains/dokka | |
parent | 5c98d42ec08ca1413f920e4f5dde28d330e8837a (diff) | |
download | dokka-bfd41ce2a0d43419a671961c19b7d755cffdcfc8.tar.gz dokka-bfd41ce2a0d43419a671961c19b7d755cffdcfc8.tar.bz2 dokka-bfd41ce2a0d43419a671961c19b7d755cffdcfc8.zip |
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
Diffstat (limited to 'integration-tests/src/main/kotlin/org/jetbrains/dokka')
-rw-r--r-- | integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt index a47adbc4..fcf6b9dd 100644 --- a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt @@ -7,7 +7,9 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import java.io.File import java.net.URL +import kotlin.test.assertEquals import kotlin.test.assertFalse +import kotlin.test.assertNotNull import kotlin.test.assertTrue @RunWith(JUnit4::class) @@ -110,4 +112,57 @@ abstract class AbstractIntegrationTest { "Expected all templates to be substituted" ) } + + /** + * Asserts that [contentFiles] have no pages where content contains special visibility markers, + * such as §INTERNAL§ for `internal`, §PROTECTED§ for `protected` and §PRIVATE§ for `private` modifiers + * + * This can be used to check whether actual documented code corresponds to configured documented visibility + * + * @param contentFiles any readable content file such as html/md/rst/etc + */ + protected fun assertContentVisibility( + contentFiles: List<File>, + documentPublic: Boolean, + documentProtected: Boolean, + documentInternal: Boolean, + documentPrivate: Boolean + ) { + val hasPublic = contentFiles.any { file -> "§PUBLIC§" in file.readText() } + assertEquals(documentPublic, hasPublic, "Expected content visibility and file content do not match for public") + + val hasInternal = contentFiles.any { file -> "§INTERNAL§" in file.readText() } + assertEquals( + documentInternal, + hasInternal, + "Expected content visibility and file content do not match for internal" + ) + + val hasProtected = contentFiles.any { file -> "§PROTECTED§" in file.readText() } + assertEquals( + documentProtected, + hasProtected, + "Expected content visibility and file content do not match for protected" + ) + + val hasPrivate = contentFiles.any { file -> "§PRIVATE§" in file.readText() } + assertEquals( + documentPrivate, + hasPrivate, + "Expected content visibility and file content do not match for private" + ) + } + + /** + * Check that [outputFiles] contain specific file paths provided in [expectedFilePaths]. + * Can be used for checking whether expected folders/pages have been created. + */ + protected fun assertContainsFilePaths(outputFiles: List<File>, expectedFilePaths: List<Regex>) { + expectedFilePaths.forEach { pathRegex -> + assertNotNull( + outputFiles.any { it.absolutePath.contains(pathRegex) }, + "Expected to find a file with path regex $pathRegex, but found nothing" + ) + } + } } |