aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/model/DisplaySourceSet.kt3
-rw-r--r--plugins/base/api/base.api12
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt37
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt7
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt8
5 files changed, 43 insertions, 24 deletions
diff --git a/core/src/main/kotlin/model/DisplaySourceSet.kt b/core/src/main/kotlin/model/DisplaySourceSet.kt
index 4f1387aa..85904db6 100644
--- a/core/src/main/kotlin/model/DisplaySourceSet.kt
+++ b/core/src/main/kotlin/model/DisplaySourceSet.kt
@@ -8,8 +8,7 @@ import org.jetbrains.dokka.utilities.SelfRepresentingSingletonSet
data class DisplaySourceSet(
val sourceSetIDs: CompositeSourceSetID,
val name: String,
- val platform
- : Platform
+ val platform: Platform
) : SelfRepresentingSingletonSet<DisplaySourceSet> {
constructor(sourceSet: DokkaSourceSet) : this(
sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID),
diff --git a/plugins/base/api/base.api b/plugins/base/api/base.api
index 46955c8a..454fa4e0 100644
--- a/plugins/base/api/base.api
+++ b/plugins/base/api/base.api
@@ -664,15 +664,15 @@ public final class org/jetbrains/dokka/base/resolvers/local/DokkaLocationProvide
public final fun identifierToFilename (Ljava/lang/String;)Ljava/lang/String;
}
-protected final class org/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSet {
- public fun <init> (Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/model/DisplaySourceSet;)V
+protected final class org/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSets {
+ public fun <init> (Lorg/jetbrains/dokka/links/DRI;Ljava/util/Set;)V
public final fun component1 ()Lorg/jetbrains/dokka/links/DRI;
- public final fun component2 ()Lorg/jetbrains/dokka/model/DisplaySourceSet;
- public final fun copy (Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/model/DisplaySourceSet;)Lorg/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSet;
- public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSet;Lorg/jetbrains/dokka/links/DRI;Lorg/jetbrains/dokka/model/DisplaySourceSet;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSet;
+ public final fun component2 ()Ljava/util/Set;
+ public final fun copy (Lorg/jetbrains/dokka/links/DRI;Ljava/util/Set;)Lorg/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSets;
+ public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSets;Lorg/jetbrains/dokka/links/DRI;Ljava/util/Set;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider$DRIWithSourceSets;
public fun equals (Ljava/lang/Object;)Z
public final fun getDri ()Lorg/jetbrains/dokka/links/DRI;
- public final fun getSourceSet ()Lorg/jetbrains/dokka/model/DisplaySourceSet;
+ public final fun getSourceSet ()Ljava/util/Set;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
index 5488f754..2575c204 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
@@ -5,6 +5,7 @@ import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.DisplaySourceSet
+import org.jetbrains.dokka.model.sourceSetIDs
import org.jetbrains.dokka.model.toDisplaySourceSet
import org.jetbrains.dokka.model.withDescendants
import org.jetbrains.dokka.pages.*
@@ -34,11 +35,19 @@ open class DokkaLocationProvider(
pageGraphRoot.children.forEach { registerPath(it, emptyList()) }
}
- protected val pagesIndex: Map<DRIWithSourceSet, ContentPage> =
+ protected val pagesIndex: Map<DRIWithSourceSets, ContentPage> =
pageGraphRoot.withDescendants().filterIsInstance<ContentPage>()
.flatMap { page ->
page.dri.flatMap { dri ->
- page.sourceSets().ifEmpty { setOf(null) }.map { sourceSet -> DRIWithSourceSet(dri,sourceSet) to page }
+ page.sourceSets().ifEmpty { setOf(null) }
+ .map { sourceSet -> DRIWithSourceSets(dri, setOfNotNull(sourceSet)) to page }
+ .let {
+ if (it.size > 1) {
+ it + (DRIWithSourceSets(dri, page.sourceSets()) to page)
+ } else {
+ it
+ }
+ }
}
}
.groupingBy { it.first }
@@ -46,7 +55,7 @@ open class DokkaLocationProvider(
if (first) page else throw AssertionError("Multiple pages associated with key: ${key.dri}/${key.sourceSet}")
}
- protected val anchorsIndex: Map<DRIWithSourceSet, PageWithKind> =
+ protected val anchorsIndex: Map<DRIWithSourceSets, PageWithKind> =
pageGraphRoot.withDescendants().filterIsInstance<ContentPage>()
.flatMap { page ->
page.content.withDescendants()
@@ -60,7 +69,7 @@ open class DokkaLocationProvider(
.flatMap { (pair, kind) ->
val (dri, sourceSets) = pair
sourceSets.ifEmpty { setOf(null) }.map { sourceSet ->
- DRIWithSourceSet(dri, sourceSet) to PageWithKind(page, kind)
+ DRIWithSourceSets(dri, setOfNotNull(sourceSet)) to PageWithKind(page, kind)
}
}
}.toMap()
@@ -70,18 +79,18 @@ open class DokkaLocationProvider(
override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?): String? =
sourceSets.ifEmpty { setOf(null) }.mapNotNull { sourceSet ->
- val driWithSourceSet = DRIWithSourceSet(dri, sourceSet)
- getLocalLocation(driWithSourceSet, context)
- ?: getLocalLocation(driWithSourceSet.copy(dri = dri.copy(target = PointingToDeclaration)), context)
+ val driWithSourceSets = DRIWithSourceSets(dri, setOfNotNull(sourceSet))
+ getLocalLocation(driWithSourceSets, context)
+ ?: getLocalLocation(driWithSourceSets.copy(dri = dri.copy(target = PointingToDeclaration)), context)
// Not found in PageGraph, that means it's an external link
?: getExternalLocation(dri, sourceSets)
?: getExternalLocation(dri.copy(target = PointingToDeclaration), sourceSets)
}.distinct().singleOrNull()
- private fun getLocalLocation(driWithSourceSet: DRIWithSourceSet, context: PageNode?): String? {
- val (dri, originalSourceSet) = driWithSourceSet
+ private fun getLocalLocation(driWithSourceSets: DRIWithSourceSets, context: PageNode?): String? {
+ val (dri, originalSourceSet) = driWithSourceSets
val allSourceSets =
- listOf(originalSourceSet) + originalSourceSet?.let { oss ->
+ listOf(originalSourceSet) + originalSourceSet.let { oss ->
dokkaContext.configuration.sourceSets.filter { it.sourceSetID in oss.sourceSetIDs }
.flatMap { it.dependentSourceSets }
.mapNotNull { ssid ->
@@ -90,10 +99,10 @@ open class DokkaLocationProvider(
}.orEmpty()
return allSourceSets.asSequence().mapNotNull { displaySourceSet ->
- pagesIndex[DRIWithSourceSet(dri, displaySourceSet)]?.let { page -> resolve(page, context) }
- ?: anchorsIndex[driWithSourceSet]?.let { (page, kind) ->
+ pagesIndex[DRIWithSourceSets(dri, displaySourceSet)]?.let { page -> resolve(page, context) }
+ ?: anchorsIndex[driWithSourceSets]?.let { (page, kind) ->
val dci = DCI(setOf(dri), kind)
- resolve(page, context) + "#" + anchorForDCI(dci, setOfNotNull(displaySourceSet))
+ resolve(page, context) + "#" + anchorForDCI(dci, displaySourceSet)
}
}.firstOrNull()
}
@@ -130,7 +139,7 @@ open class DokkaLocationProvider(
private val PageNode.pathName: String
get() = if (this is PackagePageNode) name else identifierToFilename(name)
- protected data class DRIWithSourceSet(val dri: DRI, val sourceSet: DisplaySourceSet?)
+ protected data class DRIWithSourceSets(val dri: DRI, val sourceSet: Set<DisplaySourceSet>)
protected data class PageWithKind(val page: ContentPage, val kind: Kind)
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 4eacf359..2fb70fc8 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
@@ -1,5 +1,7 @@
package org.jetbrains.dokka.base.transformers.pages.merger
+import org.jetbrains.dokka.base.renderers.sourceSets
+import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.DokkaLogger
@@ -19,7 +21,7 @@ class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStra
dri = dri,
name = name,
children = members.flatMap { it.children }.distinct(),
- content = squashDivergentInstances(members),
+ content = squashDivergentInstances(members).withSourceSets(members.allSourceSets()),
embeddedResources = members.flatMap { it.embeddedResources }.distinct(),
documentable = null
)
@@ -27,6 +29,9 @@ class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStra
return (pages - members) + listOf(merged)
}
+ private fun List<MemberPageNode>.allSourceSets(): Set<DisplaySourceSet> =
+ fold(emptySet()) { acc, e -> acc + e.sourceSets() }
+
private fun squashDivergentInstances(nodes: List<MemberPageNode>): ContentNode =
nodes.map { it.content }
.reduce { acc, node ->
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index eaa4b6cd..081608d6 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -607,7 +607,13 @@ open class DefaultPageCreator(
styles = emptySet(),
extra = elementName?.let { name -> extra + SymbolAnchorHint(name, kind) } ?: extra
) {
- link(elementName.orEmpty(), elements.first().dri, kind = kind, styles = setOf(ContentStyle.RowTitle))
+ link(
+ text = elementName.orEmpty(),
+ address = elements.first().dri,
+ kind = kind,
+ styles = setOf(ContentStyle.RowTitle),
+ sourceSets = elements.sourceSets.toSet(),
+ )
divergentGroup(
ContentDivergentGroup.GroupID(name),
elements.map { it.dri }.toSet(),