From c44bf5487bd32f90a4576859548f1db0e9355a07 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Mon, 21 Feb 2022 23:06:59 +0300 Subject: Add option to merge implicit expect-actual declarations (#2316) * Add option to merge implicit expect-actual declarations * Merge entries, constructors * Fix StdLib integration test * Add doc --- core/src/main/kotlin/pages/PageNodes.kt | 29 ++++++++++++++++++----------- core/src/main/kotlin/pages/Pages.kt | 8 ++++---- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'core/src/main/kotlin/pages') diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt index 9fc4d6e8..75e27dcc 100644 --- a/core/src/main/kotlin/pages/PageNodes.kt +++ b/core/src/main/kotlin/pages/PageNodes.kt @@ -18,9 +18,14 @@ interface PageNode : WithChildren { interface ContentPage : PageNode { val content: ContentNode val dri: Set - val documentable: Documentable? val embeddedResources: List + @Deprecated("Deprecated. Remove its usages from your code.", + ReplaceWith("documentables.firstOrNull()") + ) + val documentable: Documentable? + get() = if (this is WithDocumentables) this.documentables.firstOrNull() else null + fun modified( name: String = this.name, content: ContentNode = this.content, @@ -30,6 +35,10 @@ interface ContentPage : PageNode { ): ContentPage } +interface WithDocumentables { + val documentables: List +} + abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode { val parentMap: Map by lazy { IdentityHashMap().apply { @@ -64,7 +73,7 @@ abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode { class ModulePageNode( override val name: String, override val content: ContentNode, - override val documentable: Documentable?, + override val documentables: List = listOf(), override val children: List, override val embeddedResources: List = listOf() ) : RootPageNode(), ModulePage { @@ -81,14 +90,14 @@ class ModulePageNode( children: List ): ModulePageNode = if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this - else ModulePageNode(name, content, documentable, children, embeddedResources) + else ModulePageNode(name, content, documentables, children, embeddedResources) } class PackagePageNode( override val name: String, override val content: ContentNode, override val dri: Set, - override val documentable: Documentable?, + override val documentables: List = listOf(), override val children: List, override val embeddedResources: List = listOf() ) : PackagePage { @@ -108,14 +117,14 @@ class PackagePageNode( children: List ): PackagePageNode = if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this - else PackagePageNode(name, content, dri, documentable, children, embeddedResources) + else PackagePageNode(name, content, dri, documentables, children, embeddedResources) } class ClasslikePageNode( override val name: String, override val content: ContentNode, override val dri: Set, - override val documentable: Documentable?, + override val documentables: List = listOf(), override val children: List, override val embeddedResources: List = listOf() ) : ClasslikePage { @@ -130,14 +139,14 @@ class ClasslikePageNode( children: List ): ClasslikePageNode = if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this - else ClasslikePageNode(name, content, dri, documentable, children, embeddedResources) + else ClasslikePageNode(name, content, dri, documentables, children, embeddedResources) } class MemberPageNode( override val name: String, override val content: ContentNode, override val dri: Set, - override val documentable: Documentable?, + override val documentables: List = listOf(), override val children: List = emptyList(), override val embeddedResources: List = listOf() ) : MemberPage { @@ -152,7 +161,7 @@ class MemberPageNode( children: List ): MemberPageNode = if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this - else MemberPageNode(name, content, dri, documentable, children, embeddedResources) + else MemberPageNode(name, content, dri, documentables, children, embeddedResources) } @@ -165,8 +174,6 @@ class MultimoduleRootPageNode( override val children: List = emptyList() - override val documentable: Documentable? = null - override fun modified(name: String, children: List): RootPageNode = MultimoduleRootPageNode(dri, content, embeddedResources) diff --git a/core/src/main/kotlin/pages/Pages.kt b/core/src/main/kotlin/pages/Pages.kt index b65e72d6..90ae09e8 100644 --- a/core/src/main/kotlin/pages/Pages.kt +++ b/core/src/main/kotlin/pages/Pages.kt @@ -2,10 +2,10 @@ package org.jetbrains.dokka.pages interface MultimoduleRootPage : ContentPage -interface ModulePage : ContentPage +interface ModulePage : ContentPage, WithDocumentables -interface PackagePage : ContentPage +interface PackagePage : ContentPage, WithDocumentables -interface ClasslikePage : ContentPage +interface ClasslikePage : ContentPage, WithDocumentables -interface MemberPage : ContentPage \ No newline at end of file +interface MemberPage : ContentPage, WithDocumentables \ No newline at end of file -- cgit