aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt9
-rw-r--r--plugins/base/src/test/kotlin/model/JavaTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt1
-rw-r--r--plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt42
-rw-r--r--plugins/base/src/test/kotlin/utils/ModelUtils.kt1
5 files changed, 50 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index bc45337a..ed5b8c86 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -493,7 +493,7 @@ private class DokkaDescriptorVisitor(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
(descriptor.getAnnotations() + descriptor.fileLevelAnnotations()).toSourceSetDependent()
.toAnnotations(),
- ObviousMember.takeIf { descriptor.isFake },
+ ObviousMember.takeIf { descriptor.isObvious },
)
)
}
@@ -1038,8 +1038,11 @@ private class DokkaDescriptorVisitor(
?.parallelMap { it.toAnnotation(scope = Annotations.AnnotationScope.FILE) }
.orEmpty()
- private val FunctionDescriptor.isFake: Boolean
- get() = kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE || kind == CallableMemberDescriptor.Kind.SYNTHESIZED
+ private val FunctionDescriptor.isObvious: Boolean
+ get() = kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE ||
+ kind == CallableMemberDescriptor.Kind.SYNTHESIZED ||
+ containingDeclaration.fqNameOrNull()?.asString()
+ ?.let { it == "kotlin.Any" || it == "kotlin.Enum" } == true
}
private data class AncestryLevel(
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt
index 6220cc50..72342962 100644
--- a/plugins/base/src/test/kotlin/model/JavaTest.kt
+++ b/plugins/base/src/test/kotlin/model/JavaTest.kt
@@ -306,7 +306,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with((this / "java" / "E").cast<DEnum>()) {
name equals "E"
entries counts 1
- functions.sortedBy { it.name }.map { it.dri } equals listOf(
+ functions.sortedBy { it.name }.filter { it.name == "valueOf" || it.name == "values" }.map { it.dri } equals listOf(
DRI("java", "E", DRICallable("valueOf", null, listOf(JavaClassReference("java.lang.String"))), PointingToDeclaration),
DRI("java", "E", DRICallable("values", null, emptyList()), PointingToDeclaration),
)
diff --git a/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt b/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt
index 1a2e9fa3..ef36d811 100644
--- a/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt
+++ b/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt
@@ -46,6 +46,7 @@ class DivisionSwitchTest : BaseAbstractTest() {
sourceRoots = listOf("src/")
}
}
+ suppressObviousFunctions = false
pluginsConfigurations.addIfNotNull(
PluginConfigurationImpl(
DokkaBase::class.qualifiedName!!,
diff --git a/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt b/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt
index 01641131..d666b8a7 100644
--- a/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt
+++ b/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt
@@ -40,6 +40,23 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() {
}
@Test
+ fun `should suppress toString, equals and hashcode for interface`() {
+ testInline(
+ """
+ /src/suppressed/Suppressed.kt
+ package suppressed
+ interface Suppressed
+ """.trimIndent(),
+ suppressingConfiguration
+ ) {
+ preMergeDocumentablesTransformationStage = { modules ->
+ val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions }
+ assertEquals(0, functions.size)
+ }
+ }
+ }
+
+ @Test
fun `should suppress toString, equals and hashcode in Java`() {
testInline(
"""
@@ -121,6 +138,23 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() {
}
@Test
+ fun `not should suppress toString, equals and hashcode for interface if custom config is provided`() {
+ testInline(
+ """
+ /src/suppressed/Suppressed.kt
+ package suppressed
+ interface Suppressed
+ """.trimIndent(),
+ nonSuppressingConfiguration
+ ) {
+ preMergeDocumentablesTransformationStage = { modules ->
+ val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions }
+ assertEquals(listOf("equals", "hashCode", "toString").sorted(), functions.map { it.name }.sorted())
+ }
+ }
+ }
+
+ @Test
fun `should not suppress toString, equals and hashcode if custom config is provided in Java`() {
testInline(
"""
@@ -136,7 +170,13 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() {
//I would normally just assert names but this would make it JDK dependent, so this is better
assertEquals(
5,
- setOf("equals", "hashCode", "toString", "notify", "notifyAll").intersect(functions.map { it.name }).size
+ setOf(
+ "equals",
+ "hashCode",
+ "toString",
+ "notify",
+ "notifyAll"
+ ).intersect(functions.map { it.name }).size
)
}
}
diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt
index 24bf87c0..116759f3 100644
--- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt
@@ -16,6 +16,7 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo
block: DModule.() -> Unit
) {
val testConfiguration = configuration ?: dokkaConfiguration {
+ suppressObviousFunctions = false
sourceSets {
sourceSet {
sourceRoots = listOf("src/")