diff options
Diffstat (limited to 'plugins/base')
-rw-r--r-- | plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt | 26 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt | 29 |
2 files changed, 48 insertions, 7 deletions
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<DescriptorDocumentableSource>()?.descriptor - .safeAs<CallableMemberDescriptor>() - - if (callableMemberDescriptor?.kind == FAKE_OVERRIDE) { - return true - } + .safeAs() } - return false + + return null } private fun isPrivateOrInternalApi(documentable: Documentable, sourceSet: SourceSetData): Boolean { diff --git a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt index 5be60109..fac1e060 100644 --- a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt @@ -150,6 +150,35 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { } } + @Test + fun `data class component functions do not get reported`() { + val configuration = dokkaConfiguration { + passes { + pass { + reportUndocumented = true + sourceRoots = listOf("src/main/kotlin") + } + } + } + + testInline( + """ + |/src/main/kotlin/Test.kt + |package sample + | + |/** Documented */ + |data class X(val x: Int) { + |} + """.trimIndent(), + configuration + ) { + pagesTransformationStage = { + assertNoUndocumentedReport(Regex("component")) + assertNumberOfUndocumentedReports(1) + } + } + } + @Disabled @Test fun `undocumented secondary constructor gets reported`() { |