diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-04-14 13:20:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-14 13:20:02 +0200 |
commit | f27be3dfd3fa264f946161611638ad260a0ff392 (patch) | |
tree | 74301f87584b27e17af83118947a98397e9612fc | |
parent | 09d030e1da5ddf687e2ba6927973898e19c99390 (diff) | |
download | dokka-f27be3dfd3fa264f946161611638ad260a0ff392.tar.gz dokka-f27be3dfd3fa264f946161611638ad260a0ff392.tar.bz2 dokka-f27be3dfd3fa264f946161611638ad260a0ff392.zip |
Add ability to document generated files (#1832)
3 files changed, 34 insertions, 2 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt index 17e7dd1c..70d84dc4 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt @@ -69,6 +69,10 @@ open class GradleDokkaSourceSetBuilder( .safeConvention(DokkaDefaults.skipDeprecated) @Input + val suppressGeneratedFiles: Property<Boolean> = project.objects.safeProperty<Boolean>() + .safeConvention(true) + + @Input val jdkVersion: Property<Int> = project.objects.safeProperty<Int>() .safeConvention(DokkaDefaults.jdkVersion) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt index 2813d04e..74e3d16d 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt @@ -57,7 +57,7 @@ private fun GradleDokkaSourceSetBuilder.externalDocumentationLinksWithDefaults() } private fun GradleDokkaSourceSetBuilder.suppressedFilesWithDefaults(): Set<File> { - val suppressedFilesForAndroid = if (project.isAndroidProject()) { + val suppressedGeneratedFiles = if (suppressGeneratedFiles.getSafe()) { val generatedRoot = project.buildDir.resolve("generated").absoluteFile sourceRoots .filter { it.startsWith(generatedRoot) } @@ -67,5 +67,5 @@ private fun GradleDokkaSourceSetBuilder.suppressedFilesWithDefaults(): Set<File> emptySet() } - return suppressedFiles.toSet() + suppressedFilesForAndroid + return suppressedFiles.toSet() + suppressedGeneratedFiles } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt index 68642054..6216b5d7 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt @@ -425,6 +425,34 @@ class GradleDokkaSourceSetBuilderTest { } @Test + fun suppressedFilesByDefault() { + val sourceSet = GradleDokkaSourceSetBuilder("", project) + assertTrue(sourceSet.build().suppressedFiles.isEmpty(), "Expected no suppressed files by default") + + val file = project.buildDir.resolve("generated").also { it.mkdirs() } + file.resolve("suppressed.kt").writeText("class A") + + sourceSet.sourceRoots.from(project.buildDir.resolve("generated")) + + val suppressedConfiguration = sourceSet.build() + sourceSet.suppressGeneratedFiles.set(false) + val unsuppressedConfiguration = sourceSet.build() + + assertEquals( + setOf( + project.buildDir.resolve("generated"), + project.buildDir.resolve("generated").resolve("suppressed.kt") + ), suppressedConfiguration.suppressedFiles, + "Expected all suppressed files to be present after build" + ) + + assertTrue( + unsuppressedConfiguration.suppressedFiles.isEmpty(), + "Expected no files to be suppressed by default" + ) + } + + @Test fun platform() { val sourceSet = GradleDokkaSourceSetBuilder("", project) assertEquals(Platform.DEFAULT, sourceSet.build().analysisPlatform, "Expected default platform if not specified") |