aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/main
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-05-05 20:16:05 +0300
committerGitHub <noreply@github.com>2022-05-05 20:16:05 +0300
commit88d36234b710f2ef50db9d874e25fd2378f430ac (patch)
tree7725ece7f9a6c19f4db457baa1edad2a90ba461a /plugins/javadoc/src/main
parent3fb60bc74a4ed4e4c795f2f14fa112321a3c94cc (diff)
downloaddokka-88d36234b710f2ef50db9d874e25fd2378f430ac.tar.gz
dokka-88d36234b710f2ef50db9d874e25fd2378f430ac.tar.bz2
dokka-88d36234b710f2ef50db9d874e25fd2378f430ac.zip
Make javadoc pages generation deterministic (#2479)
* Make javadoc pages generation deterministic * Rename `genericQuery` to avoid confusion with Generics
Diffstat (limited to 'plugins/javadoc/src/main')
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt10
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt27
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt2
3 files changed, 31 insertions, 8 deletions
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
index 6c7691cd..cafc6c3e 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
@@ -317,17 +317,19 @@ class DeprecatedNode(val name: String, val address: DRI, val description: List<C
override fun hashCode(): Int = address.hashCode()
}
-enum class DeprecatedPageSection(val id: String, val caption: String, val header: String, val priority: Int = 100) {
- DeprecatedForRemoval("forRemoval", "For Removal", "Element", priority = 90),
+enum class DeprecatedPageSection(val id: String, val caption: String, val header: String) {
DeprecatedModules("module", "Modules", "Module"),
DeprecatedInterfaces("interface", "Interfaces", "Interface"),
DeprecatedClasses("class", "Classes", "Class"),
- DeprecatedEnums("enum", "Enums", "Enum"),
DeprecatedExceptions("exception", "Exceptions", "Exceptions"),
DeprecatedFields("field", "Fields", "Field"),
DeprecatedMethods("method", "Methods", "Method"),
DeprecatedConstructors("constructor", "Constructors", "Constructor"),
- DeprecatedEnumConstants("enum.constant", "Enum Constants", "Enum Constant")
+ DeprecatedEnums("enum", "Enums", "Enum"),
+ DeprecatedEnumConstants("enum.constant", "Enum Constants", "Enum Constant"),
+ DeprecatedForRemoval("forRemoval", "For Removal", "Element");
+
+ internal fun getPosition() = ordinal
}
class IndexPage(
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 057b9e85..4438e7e9 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
@@ -90,9 +90,30 @@ object IndexGenerator : PageTransformer {
}
val keys = elements.keys.sortedBy { it }
val sortedElements = elements.entries.sortedBy { (a, _) -> a }
- return input.modified(children = input.children + sortedElements.mapIndexed { i, (_, set) ->
- IndexPage(i + 1, set.sortedBy { it.getId().toLowerCase() }, keys, input.sourceSets())
- })
+
+ val indexNodeComparator = compareBy<NavigableJavadocNode> { it.getId().toLowerCase() }
+ .thenBy { it.getFullComparatorKey() }
+
+ val indexPages = sortedElements.mapIndexed { idx, (_, set) ->
+ IndexPage(
+ id = idx + 1,
+ elements = set.sortedWith(indexNodeComparator),
+ keys = keys,
+ sourceSet = input.sourceSets()
+ )
+ }
+ 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()
+
+ "$packageName/$className/$callableName/$parameters"
+ }
}
}
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt
index a6eda405..45fa3f2e 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt
@@ -81,7 +81,7 @@ internal class JavadocContentToTemplateMapTranslator(
"id" to node.name,
"title" to "Deprecated",
"kind" to "deprecated",
- "sections" to node.elements.toList().sortedBy { (section, _) -> section.priority }
+ "sections" to node.elements.toList().sortedBy { (section, _) -> section.getPosition() }
.map { (s, e) -> templateMapForDeprecatedPageSection(s, e) }
)