From 7b1020e2d413602a36b69071385e6b4f406961f3 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 3 Oct 2018 04:20:22 +0300 Subject: Render platforms on overload group level if platforms are similar --- .../main/kotlin/Formats/StructuredFormatService.kt | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'core/src') diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index e12a7923..8b66f187 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -378,13 +378,24 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } private fun formatOverloadGroup(items: List, isSingleNode: Boolean = false) { + + val platformsPerGroup = sameVersionAndPlatforms( + items.flatMap { if (it.kind == NodeKind.GroupNode) it.origins else listOf(it) } + .map { effectivePlatformAndVersion(it) } + ) + + if (platformsPerGroup) { + appendAsPlatformDependentBlock(effectivePlatformAndVersion(items)) { platforms -> + appendPlatforms(platforms) + } + } for ((index, item) in items.withIndex()) { if (index > 0) appendLine() if (item.kind == NodeKind.GroupNode) { - renderGroupNode(item, isSingleNode) + renderGroupNode(item, isSingleNode, !platformsPerGroup) } else { - renderSimpleNode(item, isSingleNode) + renderSimpleNode(item, isSingleNode, !platformsPerGroup) } } @@ -419,7 +430,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } - fun renderSimpleNode(item: DocumentationNode, isSingleNode: Boolean) { + fun renderSimpleNode(item: DocumentationNode, isSingleNode: Boolean, withPlatforms: Boolean = true) { appendAsPlatformDependentBlock(effectivePlatformAndVersion(listOf(item))) { platforms -> // TODO: use summarizesignatures val rendered = languageService.render(item) @@ -427,7 +438,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, if (item.kind !in NodeKind.classLike || !isSingleNode) appendAnchor(it.name) } - appendPlatforms(platforms) + if (withPlatforms) { + appendPlatforms(platforms) + } appendAsSignature(rendered) { appendCode { appendContent(rendered) } item.appendSourceLink() @@ -437,7 +450,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } } - fun renderGroupNode(item: DocumentationNode, isSingleNode: Boolean) { + fun renderGroupNode(item: DocumentationNode, isSingleNode: Boolean, withPlatforms: Boolean = true) { // TODO: use summarizesignatures val groupBySignature = item.origins.groupBy { languageService.render(it) @@ -451,7 +464,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, appendAnchor(it.name) } - appendPlatforms(platforms) + if (withPlatforms) { + appendPlatforms(platforms) + } appendAsSignature(sign) { appendCode { appendContent(sign) } -- cgit