diff options
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt | 15 | ||||
-rw-r--r-- | core/src/main/kotlin/Formats/StructuredFormatService.kt | 11 |
2 files changed, 20 insertions, 6 deletions
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt index 65c93e72..9ffefcab 100644 --- a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt @@ -125,10 +125,6 @@ open class KotlinWebsiteHtmlOutputBuilder( } private fun calculatePlatforms(platforms: Set<String>): Map<String, List<String>> { - - fun String.isKotlinVersion() = this.startsWith("Kotlin") - fun String.isJREVersion() = this.startsWith("JRE", ignoreCase=true) - val kotlinVersion = platforms.singleOrNull(String::isKotlinVersion)?.removePrefix("Kotlin ") val jreVersion = platforms.filter(String::isJREVersion).min()?.takeUnless { it.endsWith("6") } val targetPlatforms = platforms.filterNot { it.isKotlinVersion() || it.isJREVersion() } @@ -176,6 +172,13 @@ open class KotlinWebsiteHtmlOutputBuilder( to.append(" / ") } + override fun appendPlatformsAsText(platforms: Set<String>) { + appendHeader(5) { + to.append("For ") + platforms.filterNot { it.isJREVersion() }.joinTo(to) + } + } + override fun appendSampleBlockCode(language: String, imports: () -> Unit, body: () -> Unit) { div(to, "sample") { appendBlockCode(language) { @@ -226,3 +229,7 @@ class KotlinWebsiteHtmlFormatService @Inject constructor( override fun createOutputBuilder(to: StringBuilder, location: Location) = KotlinWebsiteHtmlOutputBuilder(to, location, generator, languageService, extension, impliedPlatforms, templateService) } + + +private fun String.isKotlinVersion() = this.startsWith("Kotlin") +private fun String.isJREVersion() = this.startsWith("JRE", ignoreCase=true)
\ No newline at end of file diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index 647f2dfb..4496d652 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -281,6 +281,13 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, appendTableRow(block) } + protected open fun appendPlatformsAsText(platforms: Set<String>) { + if (platforms.isNotEmpty()) { + appendLine() + appendText(platforms.joinToString(prefix = "(", postfix = ")")) + } + } + protected open fun appendPlatforms(platforms: Set<String>) { if (platforms.isNotEmpty()) { appendLine() @@ -388,7 +395,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, if (content.isEmpty()) continue appendAsPlatformDependentBlock(effectivePlatformsForMembers(origins)) { platforms -> if (groupByContent.count { !it.key.isEmpty() } > 1) { - appendPlatforms(platforms) + appendPlatformsAsText(platforms) } appendContent(content.summary) content.appendDescription() @@ -622,7 +629,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, if (content.isEmpty()) continue appendAsPlatformDependentBlock(effectivePlatformsForMembers(origins)) { platforms -> if (groupByContent.keys.count { !it.isEmpty() } > 1) { - appendPlatforms(platforms) + appendPlatformsAsText(platforms) } appendContent(content) } |