aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt28
1 files changed, 15 insertions, 13 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt b/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt
index b40f9afe..3b849fec 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt
@@ -5,20 +5,22 @@ import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.Kind
import org.jetbrains.dokka.utilities.DokkaLogger
+private val kindsOrder = listOf(
+ ContentKind.Classlikes,
+ ContentKind.Constructors,
+ ContentKind.Functions,
+ ContentKind.Properties,
+ ContentKind.Extensions,
+ ContentKind.Parameters,
+ ContentKind.Inheritors,
+ ContentKind.Source,
+ ContentKind.Sample,
+ ContentKind.Comment
+)
+
class DefaultTabSortingStrategy : TabSortingStrategy {
override fun <T: ContentNode> sort(tabs: Collection<T>): List<T> {
- val tabMap: Map<Kind, MutableList<T>> = mapOf(
- ContentKind.Classlikes to mutableListOf(),
- ContentKind.Constructors to mutableListOf(),
- ContentKind.Functions to mutableListOf(),
- ContentKind.Properties to mutableListOf(),
- ContentKind.Extensions to mutableListOf(),
- ContentKind.Parameters to mutableListOf(),
- ContentKind.Inheritors to mutableListOf(),
- ContentKind.Source to mutableListOf(),
- ContentKind.Sample to mutableListOf(),
- ContentKind.Comment to mutableListOf()
- )
+ val tabMap: Map<Kind, MutableList<T>> = kindsOrder.asSequence().map { it to mutableListOf<T>() }.toMap()
val unrecognized: MutableList<T> = mutableListOf()
tabs.forEach {
tabMap[it.dci.kind]?.add(it) ?: unrecognized.add(it)
@@ -26,4 +28,4 @@ class DefaultTabSortingStrategy : TabSortingStrategy {
return tabMap.values.flatten() + unrecognized
}
-} \ No newline at end of file
+}