From 2269ac5e003b1cce90742b5f5ed9cd294dd099f4 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 14 Aug 2023 19:45:32 +0200 Subject: Refactor and document DisplaySourceSet, deprecate SelfRepresentingSingletonSet (#3105) * Deprecate internal API SelfRepresentingSingletonSet for removal as being harmful and unimplement it in DisplaySourceSet * Provide no automatic migration for DisplaySourceSet, as there are no mechanisms for that. Manual migration is the replacement of 'dss' to `setOf(dss)` where applicable * Introduce a convenience-member DefaultRenderer.buildContentNode to avoid wrapping DSS into set manually * Document DisplaySourceSet * Replace Iterable.sourceSetIDs with more straightforward Iterable.computeSourceSetIds(), refactor all the usages, save some allocations * Start caching CompositeSourceSetID properties to avoid excessive allocations * Update integration tests on the latest revision with Knit version where the workaround is applied Fixes #2897 --- .../transformers/pages/sourcelinks/SourceLinksTransformer.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'plugins/base/src/main/kotlin/transformers/pages/sourcelinks') diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt index f2c3d3f0..08439ff8 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt @@ -5,10 +5,7 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.DocumentableSource -import org.jetbrains.dokka.model.WithSources -import org.jetbrains.dokka.model.sourceSetIDs +import org.jetbrains.dokka.model.* import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin @@ -87,9 +84,10 @@ class SourceLinksTransformer(val context: DokkaContext) : PageTransformer { contentNode: ContentNode, sources: Map>> ): ContentNode = contentNode.signatureGroupOrNull()?.let { sg -> + val sgIds = sg.sourceSets.computeSourceSetIds() sources[sg.dci.dri.singleOrNull()]?.let { sourceLinks -> sourceLinks - .filter { it.first.sourceSetID in sg.sourceSets.sourceSetIDs } + .filter { it.first.sourceSetID in sgIds } .takeIf { it.isNotEmpty() } ?.let { filteredSourcesLinks -> sg.copy(children = sg.children + filteredSourcesLinks.map { -- cgit