diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-07-13 15:12:18 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-07-13 15:13:01 +0200 |
commit | 2ca99df241b0fe51f533c7b1d2da416677929867 (patch) | |
tree | f3465d962eafc5a1a2bdcca4f2b9b423a6665e09 /plugins/base/src/main/kotlin | |
parent | 46bfb60f356a861097149f64bf414e732807c522 (diff) | |
download | dokka-2ca99df241b0fe51f533c7b1d2da416677929867.tar.gz dokka-2ca99df241b0fe51f533c7b1d2da416677929867.tar.bz2 dokka-2ca99df241b0fe51f533c7b1d2da416677929867.zip |
Refactor tab map creation
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/DefaultTabSortingStrategy.kt | 28 |
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 +} |