aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators/documentables
diff options
context:
space:
mode:
authorilya-g <ilya.gorbunov@jetbrains.com>2023-02-17 16:42:28 +0100
committerGitHub <noreply@github.com>2023-02-17 16:42:28 +0100
commit1fd045904e94d68878b3a5f748bf20f7c61a1cf7 (patch)
tree6e5e63033f654abc4e5c61278a4eeb39330977be /plugins/base/src/main/kotlin/translators/documentables
parentdaed35f92b3b482688856d139da6849c8e6b4ab1 (diff)
downloaddokka-1fd045904e94d68878b3a5f748bf20f7c61a1cf7.tar.gz
dokka-1fd045904e94d68878b3a5f748bf20f7c61a1cf7.tar.bz2
dokka-1fd045904e94d68878b3a5f748bf20f7c61a1cf7.zip
Consistent alphabetical order of element groups in index and navigation (#2861)
* Sort groups of divergent elements by their key first ignoring case, then preserving it * Add tests for sorting groups and navigation
Diffstat (limited to 'plugins/base/src/main/kotlin/translators/documentables')
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 25f3c450..6006af5b 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -9,6 +9,7 @@ import org.jetbrains.dokka.base.transformers.documentables.ClashingDriIdentifier
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
import org.jetbrains.dokka.base.transformers.pages.tags.CustomTagContentProvider
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder.DocumentableContentBuilder
+import org.jetbrains.dokka.base.utils.canonicalAlphabeticalOrder
import org.jetbrains.dokka.links.Callable
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
@@ -508,6 +509,9 @@ open class DefaultPageCreator(
}
}
+ private val groupKeyComparator: Comparator<Map.Entry<String?, *>> =
+ compareBy(nullsFirst(canonicalAlphabeticalOrder)) { it.key }
+
protected open fun DocumentableContentBuilder.divergentBlock(
name: String,
collection: Collection<Documentable>,
@@ -525,7 +529,7 @@ open class DefaultPageCreator(
.groupBy { it.name } // This groupBy should probably use LocationProvider
// This hacks displaying actual typealias signatures along classlike ones
.mapValues { if (it.value.any { it is DClasslike }) it.value.filter { it !is DTypeAlias } else it.value }
- .entries.sortedBy { it.key }
+ .entries.sortedWith(groupKeyComparator)
.forEach { (elementName, elements) -> // This groupBy should probably use LocationProvider
val sortedElements = sortDivergentElementsDeterministically(elements)
row(