aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt7
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt12
-rw-r--r--core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/js.kt7
-rw-r--r--core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/jvm.kt9
-rw-r--r--core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/multiplatform.md8
5 files changed, 39 insertions, 4 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index b4bb660e..84f91d9c 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka
import org.jetbrains.dokka.LanguageService.RenderMode
-import org.jetbrains.kotlin.utils.ifEmpty
import java.util.*
data class FormatLink(val text: String, val href: String)
@@ -188,6 +187,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
if (to.owner?.kind == NodeKind.GroupNode)
return link(from, to.owner!!, extension, name)
+ if (from.owner?.kind == NodeKind.GroupNode)
+ return link(from.owner!!, to, extension, name)
+
return FormatLink(name(to), locationService.relativePathToLocation(from, to))
}
@@ -226,7 +228,6 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
for ((index, item) in path.withIndex()) {
if (index > 0) {
appendBreadcrumbSeparator()
-
}
appendLink(item)
}
@@ -248,7 +249,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
open inner class PageBuilder(val nodes: Iterable<DocumentationNode>, val noHeader: Boolean = false) {
open fun build() {
val breakdownByLocation = nodes.groupBy { node ->
- node.path.filterNot { it.name.isEmpty() }.map { link(node, it) }
+ node.path.filterNot { it.name.isEmpty() }.map { link(node, it) }.distinct()
}
for ((path, nodes) in breakdownByLocation) {
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 2753e18d..c643eec2 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -309,11 +309,21 @@ class MarkdownFormatTest {
val path = "multiplatform/groupNode"
val module = buildMultiplePlatforms(path)
verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.find { it.kind == NodeKind.GroupNode }.singletonOrEmptyList())
+ markdownService.createOutputBuilder(output, tempLocation)
+ .appendNodes(listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }))
}
verifyMultiplatformPackage(module, path)
}
+ @Test fun multiplePlatformsBreadcrumbsInMemberOfMemberOfGroupNode() {
+ val path = "multiplatform/breadcrumbsInMemberOfMemberOfGroupNode"
+ val module = buildMultiplePlatforms(path)
+ verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
+ markdownService.createOutputBuilder(output, tempLocation)
+ .appendNodes(listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }?.member(NodeKind.Class)?.member(NodeKind.Function)))
+ }
+ }
+
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
val options = DocumentationOptions("", "html", generateIndexPages = false)
diff --git a/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/js.kt b/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/js.kt
new file mode 100644
index 00000000..d7fbf924
--- /dev/null
+++ b/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/js.kt
@@ -0,0 +1,7 @@
+package pack
+
+class Some {
+ fun magic() {
+
+ }
+} \ No newline at end of file
diff --git a/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/jvm.kt b/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/jvm.kt
new file mode 100644
index 00000000..57f36742
--- /dev/null
+++ b/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/jvm.kt
@@ -0,0 +1,9 @@
+package pack
+
+class SomeCoolJvmClass {
+ fun magic() {
+
+ }
+}
+
+typealias Some = SomeCoolJvmClass \ No newline at end of file
diff --git a/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/multiplatform.md b/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/multiplatform.md
new file mode 100644
index 00000000..e3d4c070
--- /dev/null
+++ b/core/testdata/format/multiplatform/breadcrumbsInMemberOfMemberOfGroupNode/multiplatform.md
@@ -0,0 +1,8 @@
+[test](test/index) / [pack](test/pack/index) / [Some](test/pack/-some/index) / [magic](test/pack/-some/-some/magic)
+
+# magic
+
+`fun magic(): Unit`
+
+**Platform and version requirements:** JS
+