diff options
Diffstat (limited to 'plugins/base/src/main/kotlin')
2 files changed, 21 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt index b0bdd4b7..66b116cc 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt @@ -4,7 +4,8 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer -abstract class SuppressedByConditionDocumentableFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { +abstract class SuppressedByConditionDocumentableFilterTransformer(val context: DokkaContext) : + PreMergeDocumentableTransformer { override fun invoke(modules: List<DModule>): List<DModule> = modules.map { module -> val (documentable, wasChanged) = processModule(module) @@ -82,7 +83,7 @@ abstract class SuppressedByConditionDocumentableFilterTransformer(val context: D } is DEnum -> { val constructors = classlike.constructors.map { processMember(it) } - val entries = classlike.entries.map { processMember(it) } + val entries = classlike.entries.map { processEnumEntry(it) } val wasClassChange = wasClasslikeChanged || (constructors + entries).any { it.changed } (classlike.takeIf { !wasClassChange } ?: classlike.copy( @@ -97,6 +98,21 @@ abstract class SuppressedByConditionDocumentableFilterTransformer(val context: D } } + private fun processEnumEntry(dEnumEntry: DEnumEntry): DocumentableWithChanges<DEnumEntry> { + if (shouldBeSuppressed(dEnumEntry)) return DocumentableWithChanges.filteredDocumentable() + + val functions = dEnumEntry.functions.map { processMember(it) } + val properties = dEnumEntry.properties.map { processMember(it) } + val classlikes = dEnumEntry.classlikes.map { processClassLike(it) } + + val wasChanged = (functions + properties + classlikes).any { it.changed } + return (dEnumEntry.takeIf { !wasChanged } ?: dEnumEntry.copy( + functions = functions.mapNotNull { it.documentable }, + classlikes = classlikes.mapNotNull { it.documentable }, + properties = properties.mapNotNull { it.documentable }, + )).let { DocumentableWithChanges(it, wasChanged) } + } + private fun <T : Documentable> processMember(member: T): DocumentableWithChanges<T> = if (shouldBeSuppressed(member)) DocumentableWithChanges.filteredDocumentable() else DocumentableWithChanges(member, false) diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index ed5b8c86..4ddd2d39 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.annotations.Annotated import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.idea.core.getDirectlyOverriddenDeclarations import org.jetbrains.kotlin.idea.kdoc.findKDoc import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink import org.jetbrains.kotlin.load.kotlin.toSourceElement @@ -48,6 +49,7 @@ import org.jetbrains.kotlin.resolve.constants.KClassValue.Value.LocalClass import org.jetbrains.kotlin.resolve.constants.KClassValue.Value.NormalClass import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull +import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeUniqueAsSequence import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.source.KotlinSourceElement import org.jetbrains.kotlin.resolve.source.PsiSourceElement @@ -1042,7 +1044,7 @@ private class DokkaDescriptorVisitor( get() = kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE || kind == CallableMemberDescriptor.Kind.SYNTHESIZED || containingDeclaration.fqNameOrNull()?.asString() - ?.let { it == "kotlin.Any" || it == "kotlin.Enum" } == true + ?.let { it == "kotlin.Any" || it == "kotlin.Enum" || it == "java.lang.Enum" || it == "java.lang.Object" } == true } private data class AncestryLevel( |