aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt2
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt6
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt10
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt6
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt3
5 files changed, 16 insertions, 11 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index 580b3f6b..0e535c86 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -129,7 +129,7 @@ class DokkaBase : DokkaPlugin() {
}
val sameMethodNameMerger by extending {
- pageMergerStrategy with SameMethodNamePageMergerStrategy order {
+ pageMergerStrategy providing { ctx -> SameMethodNamePageMergerStrategy(ctx.logger) } order {
before(fallbackMerger)
}
}
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
index eada2e3b..4d44fdef 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
@@ -76,7 +76,11 @@ open class DefaultLocationProvider(
.takeWhile { (a, b) -> a == b }.count()
return (List(contextPath.size - commonPathElements) { ".." } + nodePath.drop(commonPathElements) +
- if (node.children.isNotEmpty()) listOf(PAGE_WITH_CHILDREN_SUFFIX) else emptyList()).joinToString("/")
+ if (node is ClasslikePageNode || node.children.isNotEmpty())
+ listOf(PAGE_WITH_CHILDREN_SUFFIX)
+ else
+ emptyList()
+ ).joinToString("/")
}
private fun PageNode.parent() = pageGraphRoot.parentMap[this]
diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt
index 93d42e7e..4faf3ad4 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt
@@ -8,11 +8,11 @@ class PageMerger(private val strategies: Iterable<PageMergerStrategy>) : PageTra
override fun invoke(input: RootPageNode): RootPageNode =
input.modified(children = input.children.map { it.mergeChildren(emptyList()) })
- private fun PageNode.mergeChildren(path: List<String>): PageNode = children.groupBy { it.name }
- .map { (n, v) -> mergePageNodes(v, path + n) }
- .let { pages ->
- modified(children = pages.map { it.assertSingle(path) }.map { it.mergeChildren(path + it.name) })
- }
+ private fun PageNode.mergeChildren(path: List<String>): PageNode = children.groupBy { it::class }.map {
+ it.value.groupBy { it.name }.map { (n, v) -> mergePageNodes(v, path + n) }.map { it.assertSingle(path) }
+ }.let { pages ->
+ modified(children = pages.flatten().map { it.mergeChildren(path + it.name) })
+ }
private fun mergePageNodes(pages: List<PageNode>, path: List<String>): List<PageNode> =
strategies.fold(pages) { acc, strategy -> tryMerge(strategy, acc, path) }
diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
index 77226310..4b469eb7 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
@@ -1,17 +1,19 @@
package org.jetbrains.dokka.base.transformers.pages.merger
import org.jetbrains.dokka.pages.*
+import org.jetbrains.dokka.utilities.DokkaLogger
-object SameMethodNamePageMergerStrategy : PageMergerStrategy {
+class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStrategy {
override fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> {
val members = pages.filterIsInstance<MemberPageNode>().takeIf { it.isNotEmpty() } ?: return pages
val name = pages.first().name.also {
if (pages.any { page -> page.name != it }) { // Is this even possible?
- println("Page names for $it do not match!") // TODO pass logger here somehow
+ logger.error("Page names for $it do not match!")
}
}
val dri = members.flatMap { it.dri }.toSet()
+
val merged = MemberPageNode(
dri = dri,
name = name,
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 42db9a1d..a926857f 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -35,8 +35,7 @@ open class DefaultPageCreator(
open fun pageForPackage(p: DPackage): PackagePageNode = PackagePageNode(
p.name, contentForPackage(p), setOf(p.dri), p,
p.classlikes.map(::pageForClasslike) +
- p.functions.map(::pageForFunction) +
- p.typealiases.map(::pageForTypeAlias)
+ p.functions.map(::pageForFunction)
)
open fun pageForEnumEntry(e: DEnumEntry): ClasslikePageNode =