Skip to content

Commit

Permalink
[pkl-doc] Sort stdlib first on the main page (apple#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
HT154 committed Feb 16, 2024
1 parent 3d1db25 commit 0405db8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkl-doc/src/main/kotlin/org/pkl/doc/MainPageGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ internal class MainPageGenerator(
private fun HtmlBlockTag.renderPackages() {
if (packagesData.isEmpty()) return

val sortedPackages =
packagesData.sortedWith { pkg1, pkg2 ->
when {
pkg1.ref.pkg == "pkl" -> -1 // always sort the stdlib first
else -> pkg1.ref.pkg.compareTo(pkg2.ref.pkg)
}
}

div {
classes = setOf("member-group")

Expand All @@ -79,7 +87,7 @@ internal class MainPageGenerator(
}

ul {
for (pkg in packagesData) {
for (pkg in sortedPackages) {
val packageScope =
pageScope.packageScopes[pkg.ref.pkg]
// create scope for previously generated package
Expand Down

0 comments on commit 0405db8

Please sign in to comment.