aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-13 09:42:40 +0200
committerKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2020-10-15 03:05:14 +0200
commitcb5dbf7fd35d023d29cc00fefb0182bada323b7c (patch)
tree51c58549dc1988ccc96e8395698266a5aaed26bc /plugins/base/src/main/kotlin
parent16fb8510dba9943dd062d42c12ea44525cc5ea9f (diff)
downloaddokka-cb5dbf7fd35d023d29cc00fefb0182bada323b7c.tar.gz
dokka-cb5dbf7fd35d023d29cc00fefb0182bada323b7c.tar.bz2
dokka-cb5dbf7fd35d023d29cc00fefb0182bada323b7c.zip
Distinguish types from functions on navigation
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt3
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt3
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt10
-rw-r--r--plugins/base/src/main/kotlin/renderers/pageId.kt18
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt4
5 files changed, 33 insertions, 5 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 {