From f245defee2dcb85711ea2fbda8861314a17f14d7 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 6 Nov 2019 11:11:23 +0100 Subject: Fix merger, add platforms --- core/src/main/kotlin/renderers/HtmlRenderer.kt | 3 ++- .../DefaultDocumentationToPageTransformer.kt | 5 +++-- .../main/kotlin/transformers/TopDownPageNodeMerger.kt | 16 +++++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/core/src/main/kotlin/renderers/HtmlRenderer.kt b/core/src/main/kotlin/renderers/HtmlRenderer.kt index 065b669a..bf4090f4 100644 --- a/core/src/main/kotlin/renderers/HtmlRenderer.kt +++ b/core/src/main/kotlin/renderers/HtmlRenderer.kt @@ -35,7 +35,8 @@ open class HtmlRenderer(fileWriter: FileWriter, locationProvider: LocationProvid "" + children.filterNot { it is ContentLink }.joinToString("\n") { it.build(pageContext) } override fun buildBlock(name: String, content: List, pageContext: PageNode): String = - buildHeader(3, name) + "\n\n\n\n\n\n
\n" + content.joinToString("
") { it.build(pageContext) } + "
" + buildHeader(3, name) + "\n\n\n\n\n\n
\n" + + content.joinToString("
") { "(" + it.dci.platformDataList.map {it.platformName}.joinToString() + ") " + it.build(pageContext) } + "
" override fun renderPage(page: PageNode) { val pageText = buildStartHtml(page) + buildPageContent(page) + buildEndHtml() diff --git a/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt b/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt index ee86613b..5db50e35 100644 --- a/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt +++ b/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt @@ -65,8 +65,8 @@ class DefaultDocumentationToPageTransformer( } block("Functions", p.functions) { link(it.name, it.dri) - text(it.briefDocstring) signature(it) + text(it.briefDocstring) } } @@ -74,13 +74,14 @@ class DefaultDocumentationToPageTransformer( header(1) { text(c.name) } c.rawDocstrings.forEach { markdown(it, c) } block("Constructors", c.constructors) { + link(it.name, it.dri) signature(it) text(it.briefDocstring) } block("Functions", c.functions) { link(it.name, it.dri) - text(it.briefDocstring) signature(it) + text(it.briefDocstring) } } diff --git a/core/src/main/kotlin/transformers/TopDownPageNodeMerger.kt b/core/src/main/kotlin/transformers/TopDownPageNodeMerger.kt index 36e543b3..7d6d33b7 100644 --- a/core/src/main/kotlin/transformers/TopDownPageNodeMerger.kt +++ b/core/src/main/kotlin/transformers/TopDownPageNodeMerger.kt @@ -29,16 +29,22 @@ class TopDownPageNodeMerger { - private fun List.mergeContent(): List = - this.flatMap { it.children }.groupBy { it.dci.dri }.flatMap { (_, list) -> list.mergeList() } + private fun List.mergeContent(): ContentBlock = + ContentBlock(this.first().name, this.flatMap { it.children }.groupBy { it.dci.dri }.flatMap { (_, list) -> list.mergeList() }, DCI(this.first().dci.dri, this.flatMap { it.dci.platformDataList }.distinct()), this.flatMap { it.annotations }) private fun List.mergeList(): List = this.groupBy { it::class }.flatMap { (_, list) -> val thisClass = list.first() + val newDCI = DCI(thisClass.dci.dri, list.flatMap { it.dci.platformDataList }.distinct()) when(thisClass) { - is ContentBlock -> listOf(ContentBlock(thisClass.name, (list as List).mergeContent(), thisClass.dci, list.flatMap { it.annotations }.distinct())) - else -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "")} + is ContentBlock -> list.groupBy{ (it as ContentBlock).name }.map { (it.value as List).mergeContent() } //(ContentBlock(thisClass.name, (list as List).mergeContent(), newDCI, list.flatMap { it.annotations }.distinct())) + is ContentHeader -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "") }.map { (it as ContentHeader).copy(dci = newDCI)} + is ContentStyle -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "") }.map { (it as ContentStyle).copy(dci = newDCI)} + is ContentSymbol -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "") }.map { (it as ContentSymbol).copy(dci = newDCI)} + is ContentComment -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "") }.map { (it as ContentComment).copy(dci = newDCI)} + is ContentGroup -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "") }.map { (it as ContentGroup).copy(dci = newDCI)} + is ContentList -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "") }.map { (it as ContentList).copy(dci = newDCI)} + else -> list.distinctBy { it.toString().replace("dci=.*,".toRegex(), "") } } } - } \ No newline at end of file -- cgit