diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-10-04 06:43:27 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-10-04 06:43:27 +0300 |
commit | cbed7d1899481ec60256d9e26d47d75a3974f9ef (patch) | |
tree | 6dea283d046244769514089dc5b0f1ad9f0fe961 /core/src/main/kotlin | |
parent | bf883d16819791f9ed66fda97560f5e2f02e7506 (diff) | |
download | dokka-cbed7d1899481ec60256d9e26d47d75a3974f9ef.tar.gz dokka-cbed7d1899481ec60256d9e26d47d75a3974f9ef.tar.bz2 dokka-cbed7d1899481ec60256d9e26d47d75a3974f9ef.zip |
Hacky sort platforms on display
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r-- | core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt index b12075fb..3b2b2897 100644 --- a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt @@ -159,7 +159,9 @@ open class KotlinWebsiteHtmlOutputBuilder( val platformToVersion = calculatePlatforms(platforms).platformToVersion div(to, "tags") { div(to, "spacer") {} - platformToVersion.entries.forEach { (platform, version) -> + platformToVersion.entries.sortedBy { + platformSortWeight(it.key) + }.forEach { (platform, version) -> div(to, "tags__tag platform tag-value-$platform", otherAttributes = " data-tag-version=\"$version\"") { to.append(platform) @@ -184,8 +186,11 @@ open class KotlinWebsiteHtmlOutputBuilder( override fun appendPlatformsAsText(platforms: PlatformsData) { appendHeader(5) { - to.append("For ") - platforms.keys.filterNot { it.isJREVersion() }.joinTo(to) + val filtered = platforms.keys.filterNot { it.isJREVersion() }.sortedBy { platformSortWeight(it) } + if (filtered.isNotEmpty()) { + to.append("For ") + filtered.joinTo(to) + } } } @@ -225,6 +230,14 @@ open class KotlinWebsiteHtmlOutputBuilder( block(platforms) } } + + fun platformSortWeight(name: String) = when(name.toLowerCase()) { + "common" -> 0 + "jvm" -> 1 + "js" -> 3 + "native" -> 4 + else -> 2 // This is hack to support JRE/JUnit and so on + } } class KotlinWebsiteHtmlFormatService @Inject constructor( |