aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-04-21 10:43:56 +0200
committerGitHub <noreply@github.com>2021-04-21 10:43:56 +0200
commit6b3f33f522bd71ce41940f92b13c75bcf556251c (patch)
tree543e664825077cbda6fcf475778e655063c74bfc /plugins/base/src/main/kotlin/transformers
parent8ef365f60511ac46e8a8bb13562fab4f1de96f6d (diff)
downloaddokka-6b3f33f522bd71ce41940f92b13c75bcf556251c.tar.gz
dokka-6b3f33f522bd71ce41940f92b13c75bcf556251c.tar.bz2
dokka-6b3f33f522bd71ce41940f92b13c75bcf556251c.zip
Fix suppressing enum entries by inheritance filter (#1866)
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer.kt20
1 files changed, 18 insertions, 2 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)