diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/transformers/pages/SameNamePageMergerStrategy.kt | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/core/src/main/kotlin/transformers/pages/SameNamePageMergerStrategy.kt b/core/src/main/kotlin/transformers/pages/SameNamePageMergerStrategy.kt index 5b0e8794..47d5a2f5 100644 --- a/core/src/main/kotlin/transformers/pages/SameNamePageMergerStrategy.kt +++ b/core/src/main/kotlin/transformers/pages/SameNamePageMergerStrategy.kt @@ -3,24 +3,27 @@ package org.jetbrains.dokka.transformers.pages import org.jetbrains.dokka.pages.* object SameNamePageMergerStrategy : PageMergerStrategy { - override fun tryMerge(pages: List<PageNode>): List<PageNode> = listOf(pages.mergePageNodes()) + override fun tryMerge(pages: List<PageNode>): List<PageNode> { + val name = pages.first().name + val members = pages.filterIsInstance<MemberPageNode>() + val others = pages.filterNot { it is MemberPageNode } - private fun List<PageNode>.mergePageNodes(): ContentPage { - val name = first().name - val resChildren = this.flatMap { it.children }.distinct() - val contentChildren = this.filterIsInstance<ContentPage>() - val dri = contentChildren.flatMap { it.dri }.toSet() + val resChildren = members.flatMap { it.children }.distinct() + val dri = members.flatMap { it.dri }.toSet() val dci = DCI( dri = dri, - kind = contentChildren.first().content.dci.kind + kind = members.first().content.dci.kind ) - return contentChildren.first() - .modified( - dri = dri, - name = name, - children = resChildren, - content = asGroup(dci, contentChildren.map { it.content }) - ) + + val merged = MemberPageNode( + dri = dri, + name = name, + children = resChildren, + content = asGroup(dci, members.map { it.content }), + documentable = null + ) + + return others + listOf(merged) } fun asGroup(dci: DCI, nodes: List<ContentNode>): ContentGroup { |