From f6530934d36fbb977c2b7c4eb3669a8f581dd9f5 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Mon, 22 Jun 2020 12:15:50 +0200 Subject: Prevent ReportUndocumentedTransformer.kt from reporting "componentN" functions fromd data classes --- .../documentables/ReportUndocumentedTransformer.kt | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt index bb26ceef..7d475571 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt @@ -7,6 +7,7 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.FAKE_OVERRIDE +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED import org.jetbrains.kotlin.utils.addToStdlib.safeAs internal class ReportUndocumentedTransformer : DocumentableTransformer { @@ -45,6 +46,10 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { return false } + if (isSynthesized(documentable, sourceSet)) { + return false + } + if (isPrivateOrInternalApi(documentable, sourceSet)) { return false } @@ -124,16 +129,23 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer { } private fun isFakeOverride(documentable: Documentable, sourceSet: SourceSetData): Boolean { + return callableMemberDescriptorOrNull(documentable, sourceSet)?.kind == FAKE_OVERRIDE + } + + private fun isSynthesized(documentable: Documentable, sourceSet: SourceSetData): Boolean { + return callableMemberDescriptorOrNull(documentable, sourceSet)?.kind == SYNTHESIZED + } + + private fun callableMemberDescriptorOrNull( + documentable: Documentable, sourceSet: SourceSetData + ): CallableMemberDescriptor? { if (documentable is WithExpectActual) { - val callableMemberDescriptor = documentable.sources[sourceSet] + return documentable.sources[sourceSet] .safeAs()?.descriptor - .safeAs() - - if (callableMemberDescriptor?.kind == FAKE_OVERRIDE) { - return true - } + .safeAs() } - return false + + return null } private fun isPrivateOrInternalApi(documentable: Documentable, sourceSet: SourceSetData): Boolean { -- cgit