aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers/pages/merger
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-08-18 19:33:53 +0200
committerGitHub <noreply@github.com>2022-08-18 19:33:53 +0200
commit50a3323322265ff3b5dab1d861a25bbb1167812a (patch)
tree0966cfab6d9155724a65439a5c0d1476d66b0a7a /plugins/base/src/main/kotlin/transformers/pages/merger
parentdf8d9879b818799c83ff731b3a78e7d2b96fd8e5 (diff)
downloaddokka-50a3323322265ff3b5dab1d861a25bbb1167812a.tar.gz
dokka-50a3323322265ff3b5dab1d861a25bbb1167812a.tar.bz2
dokka-50a3323322265ff3b5dab1d861a25bbb1167812a.zip
Add deprecation details block (#2622)
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers/pages/merger')
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
index 003d68cf..87ff14a4 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
@@ -1,8 +1,11 @@
package org.jetbrains.dokka.base.transformers.pages.merger
import org.jetbrains.dokka.base.renderers.sourceSets
+import org.jetbrains.dokka.base.transformers.documentables.isDeprecated
import org.jetbrains.dokka.model.DisplaySourceSet
+import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.dfs
+import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.DokkaLogger
@@ -12,7 +15,12 @@ import org.jetbrains.dokka.utilities.DokkaLogger
*/
class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStrategy {
override fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> {
- val members = pages.filterIsInstance<MemberPageNode>().takeIf { it.isNotEmpty() } ?: return pages
+ val members = pages
+ .filterIsInstance<MemberPageNode>()
+ .takeIf { it.isNotEmpty() }
+ ?.sortedBy { it.containsDeprecatedDocumentables() } // non-deprecated first
+ ?: return pages
+
val name = pages.first().name.also {
if (pages.any { page -> page.name != it }) { // Is this even possible?
logger.error("Page names for $it do not match!")
@@ -33,6 +41,10 @@ class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStra
return (pages - members) + listOf(merged)
}
+ @Suppress("UNCHECKED_CAST")
+ private fun MemberPageNode.containsDeprecatedDocumentables() =
+ this.documentables.any { (it as? WithExtraProperties<Documentable>)?.isDeprecated() == true }
+
private fun List<MemberPageNode>.allSourceSets(): Set<DisplaySourceSet> =
fold(emptySet()) { acc, e -> acc + e.sourceSets() }