From d2aa20b041affe458509d2e27724ed7eb7127f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 14 Mar 2026 12:44:34 +0100 Subject: [PATCH] fix(dokka-mkdocs): Fix the order of the generated directories in the navigation bar --- dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt b/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt index 8aabf94..d4c49ec 100644 --- a/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt +++ b/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt @@ -134,9 +134,14 @@ abstract class DokkaMkDocsPlugin : DokkaFormatPlugin(formatName = "mkdocs") { val bR = b.relativeTo(root) when { - aR.isDirectory && aR in bR -> -1 - bR.isDirectory && bR in aR -> 1 - else -> aR.path.replace(File.separatorChar, '\u0001').decodeAsDokkaUrl().compareTo(bR.path.replace(File.separatorChar, '\u0001').decodeAsDokkaUrl()) + a.isDirectory && b in a -> -1 + b.isDirectory && a in b -> 1 + else -> { + // \u00001 because it's the smallest invisible character, so directories will be listed first + val aPath = aR.path.split(File.separatorChar).joinToString("\u0001") { it.decodeAsDokkaUrl() } + val bPath = bR.path.split(File.separatorChar).joinToString("\u0001") { it.decodeAsDokkaUrl() } + aPath.compareTo(bPath) + } } } .forEach { file -> -- 2.51.2