diff options
7 files changed, 45 insertions, 17 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 31a96110..5ca168bf 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -12,6 +12,7 @@ import org.jetbrains.dokka.base.renderers.TabSortingStrategy import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint import org.jetbrains.dokka.base.transformers.pages.sourcelinks.hasTabbedContent import org.jetbrains.dokka.base.renderers.isImage +import org.jetbrains.dokka.base.renderers.pageId import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.CompositeSourceSetID import org.jetbrains.dokka.model.DisplaySourceSet @@ -735,7 +736,7 @@ open class HtmlRenderer( buildHtml(page, page.embeddedResources) { div { id = "content" - attributes["pageIds"] = page.dri.first().toString() + attributes["pageIds"] = page.pageId content(this, page) } } diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index bc414e23..3758b8d3 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -2,6 +2,7 @@ package org.jetbrains.dokka.base.renderers.html import kotlinx.html.* import kotlinx.html.stream.createHTML +import org.jetbrains.dokka.base.renderers.pageId import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.model.WithChildren @@ -24,7 +25,7 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage { with(renderer) { div("sideMenuPart") { id = navId - attributes["pageId"] = node.dri.toString() + attributes["pageId"] = node.pageId div("overview") { buildLink(node.dri, node.sourceSets.toList()) { buildBreakableText(node.name) } if (node.children.isNotEmpty()) { diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index a87254ce..43c26dc5 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -14,6 +14,7 @@ import org.jetbrains.dokka.base.renderers.sourceSets import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.model.DEnumEntry +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.withDescendants import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext @@ -55,7 +56,7 @@ object NavigationPageInstaller : PageTransformer { private fun visit(page: ContentPage): NavigationNode = NavigationNode( - name = page.name, + name = page.displayableName, dri = page.dri.first(), sourceSets = page.sourceSets(), children = page.navigableChildren() @@ -69,6 +70,13 @@ object NavigationPageInstaller : PageTransformer { children.filter { it is ContentPage && it.documentable is DEnumEntry }.map { visit(it as ContentPage) } else -> emptyList() }.sortedBy { it.name.toLowerCase() } + + private val ContentPage.displayableName: String + get() = if(documentable is DFunction){ + "$name()" + } else { + name + } } class CustomResourceInstaller(val dokkaContext: DokkaContext) : PageTransformer { diff --git a/plugins/base/src/main/kotlin/renderers/pageId.kt b/plugins/base/src/main/kotlin/renderers/pageId.kt new file mode 100644 index 00000000..b80121c0 --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/pageId.kt @@ -0,0 +1,18 @@ +package org.jetbrains.dokka.base.renderers + +import org.jetbrains.dokka.base.renderers.html.NavigationNode +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.model.DisplaySourceSet +import org.jetbrains.dokka.pages.ContentPage + +internal val ContentPage.pageId: String + get() = pageId(dri.first(), sourceSets()) + +internal val NavigationNode.pageId: String + get() = pageId(dri, sourceSets) + +/** + * Page Id is required to have a sourceSet in order to distinguish between different pages that has same DRI but different sourceSet + * like main functions that are not expect/actual + */ +private fun pageId(dri: DRI, sourceSets: Set<DisplaySourceSet>): String = "$dri/${sourceSets.hashCode()}"
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 4582fd67..c2b27d74 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -64,7 +64,7 @@ open class DefaultPageCreator( } private fun <T> T.toClashedName() where T: Documentable, T: WithExtraProperties<T> = - name.orEmpty() + (extra[ClashingDriIdentifier]?.value?.joinToString(", ", "(", ")") { it.displayName } ?: "") + (extra[ClashingDriIdentifier]?.value?.joinToString(", ", "[", "]") { it.displayName } ?: "") + name.orEmpty() private fun <T> List<T>.renameClashingDocumentable(): List<T> where T: Documentable = groupBy { it.dri }.values.flatMap { elements -> @@ -502,7 +502,7 @@ open class DefaultPageCreator( } divergentGroup(ContentDivergentGroup.GroupID("member")) { instance(setOf(d.dri), d.sourceSets.toSet()) { - divergent(kind = ContentKind.Symbol) { + divergent { +buildSignature(d) } after { diff --git a/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt index c1d2c5a9..4bb68a6a 100644 --- a/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt +++ b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt @@ -143,27 +143,27 @@ class ExpectActualsTest : AbstractCoreTest() { ) { pagesTransformationStage = { val allChildren = it.withDescendants().filterIsInstance<ClasslikePageNode>().toList() - val commonJ = allChildren.filter { it.name == "A(jvm, js)" } - val commonN1 = allChildren.filter { it.name == "A(mingwX64, linuxX64)" } - val commonN2 = allChildren.filter { it.name == "A(iosX64, iosArm64)" } + val commonJ = allChildren.filter { it.name == "[jvm, js]A" } + val commonN1 = allChildren.filter { it.name == "[mingwX64, linuxX64]A" } + val commonN2 = allChildren.filter { it.name == "[iosX64, iosArm64]A" } val noClass = allChildren.filter { it.name == "A" } - assertTrue(commonJ.size == 1) { "There can be only one A(jvm, js) page" } + assertTrue(commonJ.size == 1) { "There can be only one [jvm, js]A page" } assertTrue( commonJ.first().documentable?.sourceSets?.map { it.displayName } ?.containsAll(listOf("commonJ", "js", "jvm")) ?: false ) { "A(jvm, js)should have commonJ, js, jvm sources" } - assertTrue(commonN1.size == 1) { "There can be only one A(mingwX64, linuxX64) page" } + assertTrue(commonN1.size == 1) { "There can be only one [mingwX64, linuxX64]A page" } assertTrue( commonN1.first().documentable?.sourceSets?.map { it.displayName } ?.containsAll(listOf("commonN1", "linuxX64", "mingwX64")) ?: false - ) { "A(mingwX64, linuxX64) should have commonN1, linuxX64, mingwX64 sources" } + ) { "[mingwX64, linuxX64]A should have commonN1, linuxX64, mingwX64 sources" } - assertTrue(commonN2.size == 1) { "There can be only one A(iosX64, iosArm64) page" } + assertTrue(commonN2.size == 1) { "There can be only one [iosX64, iosArm64]A page" } assertTrue( commonN2.first().documentable?.sourceSets?.map { it.displayName } ?.containsAll(listOf("commonN2", "iosArm64", "iosX64")) ?: false - ) { "A(iosX64, iosArm64) should have commonN2, iosArm64, iosX64 sources" } + ) { "[iosX64, iosArm64]A should have commonN2, iosArm64, iosX64 sources" } assertTrue(noClass.isEmpty()) { "There can't be any A page" } } diff --git a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt index 49fe8d5a..a8a9cb69 100644 --- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt +++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt @@ -174,14 +174,14 @@ class PageNodeMergerTest : AbstractCoreTest() { pagesTransformationStage = { println(it) val allChildren = it.childrenRec().filterIsInstance<ClasslikePageNode>() - val jvmClass = allChildren.filter { it.name == "DoNotMerge(jvm)" } - val jsClass = allChildren.filter { it.name == "DoNotMerge(js)" } + val jvmClass = allChildren.filter { it.name == "[jvm]DoNotMerge" } + val jsClass = allChildren.filter { it.name == "[js]DoNotMerge" } val noClass = allChildren.filter { it.name == "DoNotMerge" } assertTrue(jvmClass.size == 1) { "There can be only one DoNotMerge(jvm) page" } - assertTrue(jvmClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "jvm") { "DoNotMerge(jvm) should have only jvm sources" } + assertTrue(jvmClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "jvm") { "[jvm]DoNotMerge should have only jvm sources" } assertTrue(jsClass.size == 1) { "There can be only one DoNotMerge(js) page" } - assertTrue(jsClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "js") { "DoNotMerge(js) should have only js sources" } + assertTrue(jsClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "js") { "[js]DoNotMerge should have only js sources" } assertTrue(noClass.isEmpty()) { "There can't be any DoNotMerge page" } } |