From 5719e5c5f7d90aa606421381a0e4e4ffbf1b9066 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 3 Oct 2018 04:09:09 +0300 Subject: Append notices platforms as header instead of tags --- .../main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt | 15 +++++++++++---- core/src/main/kotlin/Formats/StructuredFormatService.kt | 11 +++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'core/src/main') 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): Map> { - - 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) { + 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) { + if (platforms.isNotEmpty()) { + appendLine() + appendText(platforms.joinToString(prefix = "(", postfix = ")")) + } + } + protected open fun appendPlatforms(platforms: Set) { 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) } -- cgit