blob: f53cdb12683b617633f11245f924e125f9aa3336 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package org.jetbrains.dokka.pages
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.Platform
data class ContentSourceSet(
val sourceSetIDs: CompositeSourceSetID,
val displayName: String,
val analysisPlatform: Platform
) {
constructor(sourceSet: DokkaSourceSet) : this(
sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID),
displayName = sourceSet.displayName,
analysisPlatform = sourceSet.analysisPlatform
)
operator fun contains(sourceSetID: DokkaSourceSetID): Boolean {
return sourceSetID in sourceSetIDs
}
operator fun contains(sourceSet: DokkaSourceSet): Boolean {
return sourceSet.sourceSetID in this
}
}
data class CompositeSourceSetID(
private val children: Set<DokkaSourceSetID>
) {
constructor(sourceSetIDs: Iterable<DokkaSourceSetID>) : this(sourceSetIDs.toSet())
constructor(sourceSetId: DokkaSourceSetID) : this(setOf(sourceSetId))
init {
require(children.isNotEmpty()) { "Expected at least one source set id" }
}
val merged = DokkaSourceSetID(
moduleName = children.map { it.moduleName }.reduce { acc, s -> "$acc+$s" },
sourceSetName = children.map { it.sourceSetName }.reduce { acc, s -> "$acc+$s" }
)
val all: List<DokkaSourceSetID> = listOf(merged, *children.toTypedArray())
operator fun contains(sourceSetId: DokkaSourceSetID): Boolean {
return sourceSetId in all
}
operator fun contains(sourceSet: DokkaSourceSet): Boolean {
return sourceSet.sourceSetID in this
}
}
fun DokkaSourceSet.toContentSourceSet(): ContentSourceSet = ContentSourceSet(this)
fun Iterable<DokkaSourceSet>.toContentSourceSets(): Set<ContentSourceSet> = map { it.toContentSourceSet() }.toSet()
val Iterable<ContentSourceSet>.sourceSetIDs: List<DokkaSourceSetID> get() = this.flatMap { it.sourceSetIDs.all }
|