diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-04-26 23:37:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 23:37:34 +0300 |
commit | a43f710c7802f418f8ca3b41ef8ac726c75987aa (patch) | |
tree | b87862c9ca1e6e0ff4ef25c14830b3fdcc6f0fdc /plugins/base/src/main/kotlin | |
parent | 52d066c10a50b0e34f1c390c965a89ae403e07a9 (diff) | |
download | dokka-a43f710c7802f418f8ca3b41ef8ac726c75987aa.tar.gz dokka-a43f710c7802f418f8ca3b41ef8ac726c75987aa.tar.bz2 dokka-a43f710c7802f418f8ca3b41ef8ac726c75987aa.zip |
Fix reversed ordering of enum entries (#2469)
* Fix reversed ordering of enum entries
Fixes #2466
* Add navigation sideMenu unit tests
* Make enum entries in tests non alphabetical
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt | 24 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt | 2 |
2 files changed, 16 insertions, 10 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 3297d09f..4527baa7 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -26,15 +26,21 @@ abstract class NavigationDataProvider { children = page.navigableChildren() ) - private fun ContentPage.navigableChildren(): List<NavigationNode> = - when { - this !is ClasslikePageNode -> - children.filterIsInstance<ContentPage>().map { visit(it) } - documentables.any { it is DEnum } -> - children.filter { it is WithDocumentables && it.documentables.any { it is DEnumEntry } } - .map { visit(it as ContentPage) } - else -> emptyList() - }.sortedBy { it.name.toLowerCase() } + private fun ContentPage.navigableChildren(): List<NavigationNode> { + return if (this !is ClasslikePageNode) { + children + .filterIsInstance<ContentPage>() + .map { visit(it) } + .sortedBy { it.name.toLowerCase() } + } else if (documentables.any { it is DEnum }) { + // no sorting for enum entries, should be the same as in source code + children + .filter { child -> child is WithDocumentables && child.documentables.any { it is DEnumEntry } } + .map { visit(it as ContentPage) } + } else { + emptyList() + } + } /** * Parenthesis is applied in 1 case: diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt index 4b9da03b..4ca3d861 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt @@ -216,7 +216,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe } private fun filterEnumEntries(entries: List<DEnumEntry>, filteredPlatforms: Set<DokkaSourceSet>): Pair<Boolean, List<DEnumEntry>> = - entries.foldRight(Pair(false, emptyList())) { entry, acc -> + entries.fold(Pair(false, emptyList())) { acc, entry -> val intersection = filteredPlatforms.intersect(entry.sourceSets) if (intersection.isEmpty()) Pair(true, acc.second) else { |