From 0f19897ef9de71f571b1af703ac33923640cb547 Mon Sep 17 00:00:00 2001
From: Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com>
Date: Tue, 2 Oct 2018 03:23:01 +0300
Subject: Fix single node & group node pages platform display

---
 core/src/main/kotlin/Formats/StructuredFormatService.kt | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

(limited to 'core/src')

diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index eda85031..67e8c503 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -392,7 +392,6 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
                 if (!item.content.isEmpty()) {
                     val platforms = effectivePlatformsForNode(item)
                     appendAsPlatformDependentBlock(platforms) {
-                        appendPlatforms(platforms)
                         appendContent(item.summary)
                         item.content.appendDescription()
                     }
@@ -409,13 +408,13 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
                     if (item.kind !in NodeKind.classLike || !isSingleNode)
                         appendAnchor(it.name)
                 }
+                appendPlatforms(platforms)
                 appendAsSignature(rendered) {
                     appendCode { appendContent(rendered) }
                     item.appendSourceLink()
                 }
                 item.appendOverrides()
                 item.appendDeprecation()
-                appendPlatforms(platforms)
             }
         }
 
@@ -433,10 +432,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
                             appendAnchor(it.name)
                     }
 
+                    appendPlatforms(platforms)
+
                     appendAsSignature(sign) {
                         appendCode { appendContent(sign) }
                     }
-                    appendPlatforms(platforms)
                     first.appendOverrides()
                     first.appendDeprecation()
                 }
@@ -611,11 +611,13 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
 
             renderGroupNode(node, true)
 
-            for ((content, origins) in node.origins.groupBy { it.content }) {
+            val groupByContent = node.origins.groupBy { it.content }
+            for ((content, origins) in groupByContent) {
                 if (content.isEmpty()) continue
-                val platforms = effectivePlatformAndVersion(origins)
-                appendAsPlatformDependentBlock(platforms) {
-                    appendPlatforms(platforms)
+                appendAsPlatformDependentBlock(effectivePlatformsForMembers(origins)) { platforms ->
+                    if (groupByContent.keys.count { !it.isEmpty() } > 1) {
+                        appendPlatforms(platforms)
+                    }
                     appendContent(content)
                 }
             }
-- 
cgit