From 50a3323322265ff3b5dab1d861a25bbb1167812a Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 18 Aug 2022 19:33:53 +0200 Subject: Add deprecation details block (#2622) --- .../pages/merger/SameMethodNamePageMergerStrategy.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'plugins/base/src/main/kotlin/transformers/pages/merger') 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, path: List): List { - val members = pages.filterIsInstance().takeIf { it.isNotEmpty() } ?: return pages + val members = pages + .filterIsInstance() + .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)?.isDeprecated() == true } + private fun List.allSourceSets(): Set = fold(emptySet()) { acc, e -> acc + e.sourceSets() } -- cgit