diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-04-21 13:10:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-21 13:10:03 +0200 |
commit | db337c6b489d41f7c62bc44f9edb3e5eaa62e0d5 (patch) | |
tree | 977bff9096271ac32635ebece028005d80ea0e89 /plugins/base/src/main | |
parent | 7976824f185ac846f687971cca449da2e4c24728 (diff) | |
download | dokka-db337c6b489d41f7c62bc44f9edb3e5eaa62e0d5.tar.gz dokka-db337c6b489d41f7c62bc44f9edb3e5eaa62e0d5.tar.bz2 dokka-db337c6b489d41f7c62bc44f9edb3e5eaa62e0d5.zip |
Make anchors stable (#1851)
* Make anchors stable
* Remove backing field from merged and all in CompositeSourceSetID
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/pageId.kt | 11 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/resolvers/local/DokkaBaseLocationProvider.kt | 3 |
2 files changed, 12 insertions, 2 deletions
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() } |