aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-06-22 12:15:50 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-06-22 12:55:58 +0200
commitf6530934d36fbb977c2b7c4eb3669a8f581dd9f5 (patch)
tree9e9501347db191fdfebb235d400e20169076222c /plugins/base/src
parent442a4651880ec2018728f64028c627776d000e9a (diff)
downloaddokka-f6530934d36fbb977c2b7c4eb3669a8f581dd9f5.tar.gz
dokka-f6530934d36fbb977c2b7c4eb3669a8f581dd9f5.tar.bz2
dokka-f6530934d36fbb977c2b7c4eb3669a8f581dd9f5.zip
Prevent ReportUndocumentedTransformer.kt from reporting "componentN" functions fromd data classes
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt26
-rw-r--r--plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt29
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`() {