From c3b798fc31779468d65538b105085a3bd945792f Mon Sep 17 00:00:00 2001
From: Błażej Kardyś <bkardys@virtuslab.com>
Date: Sat, 15 Feb 2020 20:23:54 +0100
Subject: Removing duplicated content blocks

---
 core/src/main/kotlin/model/Documentable.kt | 24 ++++++-------
 core/src/main/kotlin/pages/PageBuilder.kt  | 58 +++++++++++-------------------
 2 files changed, 31 insertions(+), 51 deletions(-)

(limited to 'core/src')

diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index 1744e27f..e64f82ac 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -190,20 +190,16 @@ abstract class Documentable {
 
     override fun hashCode() = dri.hashCode()
 
-
-    val commentsData: List<DocumentationNode>
-        get() = platformInfo.map { it.documentationNode }
-
-    val briefDocTagString: String
-        get() =
-            platformInfo
-                .firstOrNull()
-                ?.documentationNode
-                ?.children
-                ?.firstOrNull()
-                ?.root
-                ?.docTagSummary()
-                ?.shorten(40) ?: ""
+    val briefDocTagString: String by lazy {
+        platformInfo
+            .firstOrNull()
+            ?.documentationNode
+            ?.children
+            ?.firstOrNull()
+            ?.root
+            ?.docTagSummary()
+            ?.shorten(40) ?: ""
+    }
 
     open val extra: MutableSet<Extra> = mutableSetOf()
 }
diff --git a/core/src/main/kotlin/pages/PageBuilder.kt b/core/src/main/kotlin/pages/PageBuilder.kt
index e3105918..eb6f5e21 100644
--- a/core/src/main/kotlin/pages/PageBuilder.kt
+++ b/core/src/main/kotlin/pages/PageBuilder.kt
@@ -75,31 +75,21 @@ open class DefaultPageBuilder(
             header(2) { text("SuperInterfaces") }
             linkTable(it)
         }
-        c.platformInfo.forEach { platformInfo ->
-            platformInfo.documentationNode.children.forEach {
-                header(3) {
-                    text(it.toHeaderString())
-                    text("[${platformInfo.platformData.joinToString(", ") { it.platformType.name }}]")
-                }
-                comment(it.root)
-                text("\n")
-            }
-            contentForComments(c)
-            block("Constructors", 2, ContentKind.Functions, c.constructors, c.platformData) {
-                link(it.name, it.dri)
-                signature(it)
-                text(it.briefDocTagString)
-            }
+        contentForComments(c)
+        block("Constructors", 2, ContentKind.Functions, c.constructors, c.platformData) {
+            link(it.name, it.dri)
+            signature(it)
+            text(it.briefDocTagString)
+        }
+        block("Functions", 2, ContentKind.Functions, c.functions, c.platformData) {
+            link(it.name, it.dri)
+            signature(it)
+            text(it.briefDocTagString)
+        }
+        block("Properties", 2, ContentKind.Properties, c.properties, c.platformData) {
+            link(it.name, it.dri)
+            text(it.briefDocTagString)
 
-            this.block("Functions", 2, ContentKind.Functions, c.functions, c.platformData) {
-                link(it.name, it.dri)
-                signature(it)
-                text(it.briefDocTagString)
-            }
-            block("Properties", 2, ContentKind.Properties, c.properties, c.platformData) {
-                link(it.name, it.dri)
-                text(it.briefDocTagString)
-            }
         }
     }
 
@@ -133,27 +123,21 @@ open class DefaultPageBuilder(
     }
 
     private fun PageContentBuilder.contentForComments(d: Documentable) =
-        d.commentsData.forEach {
-            it.children.forEach {
-                header(3) { text(it.toHeaderString()) }
-                comment(it.root)
-                text("\n")
-            }
-        }
-
-    private fun contentForFunction(f: Function) = group(f) {
-        header(1) { text(f.name) }
-        signature(f)
-        f.platformInfo.forEach { platformInfo ->
+        d.platformInfo.forEach { platformInfo ->
             platformInfo.documentationNode.children.forEach {
                 header(3) {
                     text(it.toHeaderString())
-                    text("[${platformInfo.platformData.joinToString(", ") { it.platformType.name }}]")
+                    text(" [${platformInfo.platformData.joinToString(", ") { it.platformType.name }}]")
                 }
                 comment(it.root)
                 text("\n")
             }
         }
+
+    private fun contentForFunction(f: Function) = group(f) {
+        header(1) { text(f.name) }
+        signature(f)
+        contentForComments(f)
         block("Parameters", 2, ContentKind.Parameters, f.children, f.platformData) {
             text(it.name ?: "<receiver>")
             it.platformInfo.forEach { it.documentationNode.children.forEach { comment(it.root) } }
-- 
cgit