diff options
6 files changed, 30 insertions, 10 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index b4af636a..e9d0f3d5 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -2,6 +2,7 @@ package org.jetbrains.dokka import org.jetbrains.dokka.DokkaConfiguration.PackageOptions import ru.yole.jkid.deserialization.deserialize +import java.io.File import java.util.function.BiConsumer @@ -64,7 +65,8 @@ class DokkaBootstrapImpl : DokkaBootstrap { perPackageOptions, externalDocumentationLinks, noStdlibLink, - cacheRoot + cacheRoot, + suppressedFiles.map { File(it) } ) ) } diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt index 9b4013ad..f67582a7 100644 --- a/core/src/main/kotlin/Generation/configurationImpl.kt +++ b/core/src/main/kotlin/Generation/configurationImpl.kt @@ -53,4 +53,5 @@ data class DokkaConfigurationImpl(override val moduleName: String, override val perPackageOptions: List<PackageOptionsImpl>, override val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>, override val noStdlibLink: Boolean, - override val cacheRoot: String?) : DokkaConfiguration
\ No newline at end of file + override val cacheRoot: String?, + override val suppressedFiles: List<String>) : DokkaConfiguration
\ No newline at end of file diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 824d74bb..707831ae 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotated import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor import org.jetbrains.kotlin.idea.kdoc.findKDoc +import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl @@ -29,6 +30,7 @@ import org.jetbrains.kotlin.resolve.source.getPsi import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.supertypes +import java.io.File import java.nio.file.Path import java.nio.file.Paths import com.google.inject.name.Named as GuiceNamed @@ -48,7 +50,8 @@ class DocumentationOptions(val outputDir: String, perPackageOptions: List<PackageOptions> = emptyList(), externalDocumentationLinks: List<ExternalDocumentationLink> = emptyList(), noStdlibLink: Boolean, - cacheRoot: String? = null) { + cacheRoot: String? = null, + val suppressedFiles: List<File> = emptyList()) { init { if (perPackageOptions.any { it.prefix == "" }) throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead") @@ -783,7 +786,7 @@ fun DeclarationDescriptor.isDocumented(options: DocumentationOptions): Boolean { return (options.effectivePackageOptions(fqNameSafe).includeNonPublic || this !is MemberDescriptor || this.visibility in visibleToDocumentation) && - !isDocumentationSuppressed() && + !isDocumentationSuppressed(options) && (!options.effectivePackageOptions(fqNameSafe).skipDeprecated || !isDeprecated()) } @@ -852,7 +855,13 @@ fun AnnotationDescriptor.mustBeDocumented(): Boolean { return annotationClass.isDocumentedAnnotation() } -fun DeclarationDescriptor.isDocumentationSuppressed(): Boolean { +fun DeclarationDescriptor.isDocumentationSuppressed(options: DocumentationOptions): Boolean { + + val path = this.findPsi()?.containingFile?.virtualFile?.path + if (path != null) { + if (File(path).absoluteFile in options.suppressedFiles) return true + } + val doc = findKDoc() if (doc is KDocSection && doc.findTagByName("suppress") != null) return true diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt index b28f0713..4c4d479f 100644 --- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt +++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt @@ -38,6 +38,7 @@ interface DokkaConfiguration { val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> val noStdlibLink: Boolean val cacheRoot: String? + val suppressedFiles: List<String> interface SourceRoot { val path: String @@ -96,7 +97,8 @@ data class SerializeOnlyDokkaConfiguration(override val moduleName: String, override val perPackageOptions: List<DokkaConfiguration.PackageOptions>, override val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink>, override val noStdlibLink: Boolean, - override val cacheRoot: String?) : DokkaConfiguration + override val cacheRoot: String?, + override val suppressedFiles: List<String>) : DokkaConfiguration data class ExternalDocumentationLinkImpl(@CustomSerializer(UrlSerializer::class) override val url: URL, diff --git a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt index f392f1ab..f2261120 100644 --- a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt +++ b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt @@ -22,6 +22,11 @@ open class DokkaAndroidTask : DokkaTask() { @Input var noAndroidSdkLink: Boolean = false + override fun collectSuppressedFiles(sourceRoots: List<SourceRoot>): List<String> { + val generatedSubpath = "${project.buildDir}/generated/source".replace("/", File.separator) + return sourceRoots.filter { generatedSubpath in it.path }.flatMap { File(it.path).walk().toList() }.map { it.absolutePath } + } + init { project.afterEvaluate { if (!noAndroidSdkLink) externalDocumentationLinks.add(ANDROID_REFERENCE_URL) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index fd4053ee..0417b02a 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -231,6 +231,8 @@ open class DokkaTask : DefaultTask() { private fun Iterable<File>.toSourceRoots(): List<SourceRoot> = this.filter { it.exists() }.map { SourceRoot().apply { path = it.path } } + protected open fun collectSuppressedFiles(sourceRoots: List<SourceRoot>): List<String> = emptyList() + @TaskAction fun generate() { val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) ?: "false" @@ -276,7 +278,8 @@ open class DokkaTask : DefaultTask() { perPackageOptions, externalDocumentationLinks, noStdlibLink, - cacheRoot) + cacheRoot, + collectSuppressedFiles(sourceRoots)) bootstrapProxy.configure( @@ -326,11 +329,9 @@ open class DokkaTask : DefaultTask() { } - @SkipWhenEmpty @InputFiles fun getInputFiles(): FileCollection = - project.files(kotlinCompileBasedClasspathAndSourceRoots.sourceRoots.map { project.fileTree(File(it.path)) }) + - project.files(collectSourceRoots().map { project.fileTree(File(it.path)) }) + + project.files(collectSourceRoots().map { project.fileTree(File(it.path)) }) + project.files(includes) + project.files(samples.map { project.fileTree(it) }) |