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 --- core/src/test/kotlin/model/CompositeSourceSetIDTest.kt | 6 +++++- core/src/test/kotlin/model/DisplaySourceSetTest.kt | 10 ++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'core/src/test/kotlin/model') diff --git a/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt index 472581e7..aa5a801d 100644 --- a/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt +++ b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt @@ -2,7 +2,6 @@ package model import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.model.CompositeSourceSetID -import org.jetbrains.dokka.model.plus import kotlin.test.* class CompositeSourceSetIDTest { @@ -65,4 +64,9 @@ class CompositeSourceSetIDTest { "Expected all three source sets being merged in order" ) } + + operator fun DokkaSourceSetID.plus(other: DokkaSourceSetID): CompositeSourceSetID { + return CompositeSourceSetID(listOf(this, other)) + } + } diff --git a/core/src/test/kotlin/model/DisplaySourceSetTest.kt b/core/src/test/kotlin/model/DisplaySourceSetTest.kt index adabdbdb..04ad07d6 100644 --- a/core/src/test/kotlin/model/DisplaySourceSetTest.kt +++ b/core/src/test/kotlin/model/DisplaySourceSetTest.kt @@ -2,9 +2,7 @@ package model import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.model.CompositeSourceSetID -import org.jetbrains.dokka.model.DisplaySourceSet -import org.jetbrains.dokka.model.sourceSetIDs +import org.jetbrains.dokka.model.* import kotlin.test.Test import kotlin.test.assertFalse import kotlin.test.assertTrue @@ -44,17 +42,17 @@ class DisplaySourceSetTest { ) assertFalse( - DokkaSourceSetID("m3", "s3") in listOf(contentSourceSet).sourceSetIDs, + DokkaSourceSetID("m3", "s3") in listOf(contentSourceSet).computeSourceSetIds(), "Expected source set id not being contained in content source set" ) assertTrue( - DokkaSourceSetID("m1", "s1") in listOf(contentSourceSet).sourceSetIDs, + DokkaSourceSetID("m1", "s1") in listOf(contentSourceSet).computeSourceSetIds(), "Expected source set id being contained in content source set" ) assertTrue( - DokkaSourceSetID("m1+m2", "s1+s2") in listOf(contentSourceSet).sourceSetIDs, + DokkaSourceSetID("m1+m2", "s1+s2") in listOf(contentSourceSet).computeSourceSetIds(), "Expected merged source set being contained in content source set" ) } -- cgit