diff options
3 files changed, 22 insertions, 8 deletions
diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt index e14b01df..3eaf6407 100644 --- a/core/src/main/kotlin/model/CompositeSourceSetID.kt +++ b/core/src/main/kotlin/model/CompositeSourceSetID.kt @@ -13,12 +13,16 @@ data class CompositeSourceSetID( require(children.isNotEmpty()) { "Expected at least one source set id" } } - val merged = DokkaSourceSetID( - scopeId = children.joinToString(separator = "+") { it.scopeId }, - sourceSetName = children.joinToString(separator = "+") { it.sourceSetName } - ) - - val all: Set<DokkaSourceSetID> = setOf(merged, *children.toTypedArray()) + val merged: DokkaSourceSetID + get() = children.sortedBy { it.scopeId + it.sourceSetName }.let { sortedChildren -> + DokkaSourceSetID( + scopeId = sortedChildren.joinToString(separator = "+") { it.scopeId }, + sourceSetName = sortedChildren.joinToString(separator = "+") { it.sourceSetName } + ) + } + + val all: Set<DokkaSourceSetID> + get() = setOf(merged, *children.toTypedArray()) operator fun contains(sourceSetId: DokkaSourceSetID): Boolean { return sourceSetId in all diff --git a/plugins/base/src/main/kotlin/renderers/pageId.kt b/plugins/base/src/main/kotlin/renderers/pageId.kt index b80121c0..d3a9ed7a 100644 --- a/plugins/base/src/main/kotlin/renderers/pageId.kt +++ b/plugins/base/src/main/kotlin/renderers/pageId.kt @@ -11,8 +11,17 @@ internal val ContentPage.pageId: String internal val NavigationNode.pageId: String get() = pageId(dri, sourceSets) +@JvmName("shortenSourceSetsToUrl") +internal fun Set<DisplaySourceSet>.shortenToUrl() = + sortedBy { it.sourceSetIDs.merged.let { it.scopeId + it.sourceSetName } }.joinToString().hashCode() + +internal fun DRI.shortenToUrl() = toString() + +@JvmName("shortenDrisToUrl") +internal fun Set<DRI>.shortenToUrl() = sortedBy { it.toString() }.joinToString().hashCode() + /** * 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 +private fun pageId(dri: DRI, sourceSets: Set<DisplaySourceSet>): String = "${dri.shortenToUrl()}/${sourceSets.shortenToUrl()}"
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt index fa133045..41a9a7e2 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.base.resolvers.local +import org.jetbrains.dokka.base.renderers.shortenToUrl import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.pages.DCI import org.jetbrains.dokka.pages.RootPageNode @@ -17,6 +18,6 @@ abstract class DokkaBaseLocationProvider( * 2040 characters limit */ open fun anchorForDCI(dci: DCI, sourceSets: Set<DisplaySourceSet>): String = - (dci.dri.toString() + "/" + dci.kind + "/" + sourceSets.hashCode()).urlEncoded() + (dci.dri.shortenToUrl().toString() + "/" + dci.kind + "/" + sourceSets.shortenToUrl()).urlEncoded() } |