aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/main/kotlin/org/jetbrains
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-05-09 18:37:04 +0200
committerGitHub <noreply@github.com>2022-05-09 18:37:04 +0200
commitc4567d5a0e355a016b645352a993912694e55c21 (patch)
tree0e3c8b16160a9f4b6c962db5036c856495ca8dec /plugins/javadoc/src/main/kotlin/org/jetbrains
parent12bf21bc0814b0b85655e957ce9f3a99ef389785 (diff)
downloaddokka-c4567d5a0e355a016b645352a993912694e55c21.tar.gz
dokka-c4567d5a0e355a016b645352a993912694e55c21.tar.bz2
dokka-c4567d5a0e355a016b645352a993912694e55c21.zip
Refactor to utilize Comparators instead of String keys (#2489)
* Refactor to utilize Comparators instead of String keys
Diffstat (limited to 'plugins/javadoc/src/main/kotlin/org/jetbrains')
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt20
1 files changed, 9 insertions, 11 deletions
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
index 4438e7e9..39e2525e 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
@@ -4,6 +4,7 @@ import org.jetbrains.dokka.base.renderers.sourceSets
import org.jetbrains.dokka.base.transformers.documentables.deprecatedAnnotation
import org.jetbrains.dokka.base.transformers.documentables.isDeprecated
import org.jetbrains.dokka.base.transformers.documentables.isException
+import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.BooleanValue
import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.pages.*
@@ -91,9 +92,7 @@ object IndexGenerator : PageTransformer {
val keys = elements.keys.sortedBy { it }
val sortedElements = elements.entries.sortedBy { (a, _) -> a }
- val indexNodeComparator = compareBy<NavigableJavadocNode> { it.getId().toLowerCase() }
- .thenBy { it.getFullComparatorKey() }
-
+ val indexNodeComparator = getIndexNodeComparator()
val indexPages = sortedElements.mapIndexed { idx, (_, set) ->
IndexPage(
id = idx + 1,
@@ -105,15 +104,14 @@ object IndexGenerator : PageTransformer {
return input.modified(children = input.children + indexPages)
}
- private fun NavigableJavadocNode.getFullComparatorKey(): String {
- return getDRI().let { dri ->
- val packageName = dri.packageName.orEmpty()
- val className = dri.classNames.orEmpty()
- val callableName = dri.callable?.name.orEmpty()
- val parameters = dri.callable?.signature().orEmpty()
+ private fun getIndexNodeComparator(): Comparator<NavigableJavadocNode> {
+ val driComparator = compareBy<DRI> { it.packageName }
+ .thenBy { it.classNames }
+ .thenBy { it.callable?.name.orEmpty() }
+ .thenBy { it.callable?.signature().orEmpty() }
- "$packageName/$className/$callableName/$parameters"
- }
+ return compareBy<NavigableJavadocNode> { it.getId().toLowerCase() }
+ .thenBy(driComparator) { it.getDRI() }
}
}