aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt34
-rw-r--r--plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt49
-rw-r--r--plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt8
-rw-r--r--plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt2
4 files changed, 25 insertions, 68 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt
index a7cd171e..053aaa79 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt
@@ -1,24 +1,20 @@
package org.jetbrains.dokka.base.transformers.documentables
import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.ExtraProperty
import org.jetbrains.dokka.model.properties.MergeStrategy
-import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.model.properties.mergeExtras
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.documentation.DocumentableMerger
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
-import org.jetbrains.kotlin.utils.addToStdlib.safeAs
internal class DefaultDocumentableMerger(val context: DokkaContext) : DocumentableMerger {
private val dependencyInfo = context.getDependencyInfo()
-
override fun invoke(modules: Collection<DModule>): DModule {
- return topologicalSort(modules).reduce { left, right ->
+ return modules.reduce { left, right ->
val list = listOf(left, right)
DModule(
name = modules.map { it.name }.distinct().joinToString("|"),
@@ -32,34 +28,6 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab
}
}
- private fun topologicalSort(allModules: Collection<DModule>): List<DModule> {
-
- val modulesMap: Map<DokkaSourceSetID, ModuleOfDifferentTranslators> =
- allModules.groupBy { it.sourceSets.single().sourceSetID }
-
- //this returns representation of graph where directed edges are leading from module to modules that depend on it
- val graph: Map<ModuleOfDifferentTranslators, List<ModuleOfDifferentTranslators>> =
- modulesMap.flatMap { (_, module) ->
- module.first().sourceSets.single().dependentSourceSets.map { sourceSet ->
- modulesMap[sourceSet]!! to module
- }
- }.groupingBy { it.first }.fold({ _, value -> listOf(value.second) }) { _, accumulator, value ->
- accumulator + listOf(value.second)
- }
-
- val visited = modulesMap.map { it.value to false }.toMap().toMutableMap()
- val topologicalSortedList: MutableList<ModuleOfDifferentTranslators> = mutableListOf()
-
- fun dfs(module: ModuleOfDifferentTranslators) {
- visited[module] = true
- graph[module]?.forEach { if (!visited[it]!!) dfs(it) }
- topologicalSortedList.add(0, module)
- }
- modulesMap.values.forEach { if (!visited[it]!!) dfs(it) }
-
- return topologicalSortedList.flatten()
- }
-
private fun DokkaContext.getDependencyInfo()
: Map<DokkaConfiguration.DokkaSourceSet, List<DokkaConfiguration.DokkaSourceSet>> {
diff --git a/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt
index 624db485..ab472ae0 100644
--- a/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt
+++ b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt
@@ -15,84 +15,75 @@ class ExpectActualsTest : AbstractCoreTest() {
fun `three same named expect actual classes`() {
val configuration = dokkaConfiguration {
+ moduleName = "example"
sourceSets {
val common = sourceSet {
- moduleName = "example"
name = "common"
displayName = "common"
analysisPlatform = "common"
sourceRoots = listOf("src/commonMain/kotlin/pageMerger/Test.kt")
}
val commonJ = sourceSet {
- moduleName = "example"
name = "commonJ"
displayName = "commonJ"
analysisPlatform = "common"
sourceRoots = listOf("src/commonJMain/kotlin/pageMerger/Test.kt")
- dependentSourceSets = setOf(common.sourceSetID)
+ dependentSourceSets = setOf(common.value.sourceSetID)
}
val commonN1 = sourceSet {
- moduleName = "example"
name = "commonN1"
displayName = "commonN1"
analysisPlatform = "common"
sourceRoots = listOf("src/commonN1Main/kotlin/pageMerger/Test.kt")
- dependentSourceSets = setOf(common.sourceSetID)
+ dependentSourceSets = setOf(common.value.sourceSetID)
}
val commonN2 = sourceSet {
- moduleName = "example"
name = "commonN2"
displayName = "commonN2"
analysisPlatform = "common"
sourceRoots = listOf("src/commonN2Main/kotlin/pageMerger/Test.kt")
- dependentSourceSets = setOf(common.sourceSetID)
+ dependentSourceSets = setOf(common.value.sourceSetID)
}
val js = sourceSet {
- moduleName = "example"
name = "js"
displayName = "js"
analysisPlatform = "js"
- dependentSourceSets = setOf(commonJ.sourceSetID)
+ dependentSourceSets = setOf(commonJ.value.sourceSetID)
sourceRoots = listOf("src/jsMain/kotlin/pageMerger/Test.kt")
}
val jvm = sourceSet {
- moduleName = "example"
name = "jvm"
displayName = "jvm"
analysisPlatform = "jvm"
- dependentSourceSets = setOf(commonJ.sourceSetID)
+ dependentSourceSets = setOf(commonJ.value.sourceSetID)
sourceRoots = listOf("src/jvmMain/kotlin/pageMerger/Test.kt")
}
val linuxX64 = sourceSet {
- moduleName = "example"
name = "linuxX64"
displayName = "linuxX64"
analysisPlatform = "native"
- dependentSourceSets = setOf(commonN1.sourceSetID)
+ dependentSourceSets = setOf(commonN1.value.sourceSetID)
sourceRoots = listOf("src/linuxX64Main/kotlin/pageMerger/Test.kt")
}
val mingwX64 = sourceSet {
- moduleName = "example"
name = "mingwX64"
displayName = "mingwX64"
analysisPlatform = "native"
- dependentSourceSets = setOf(commonN1.sourceSetID)
+ dependentSourceSets = setOf(commonN1.value.sourceSetID)
sourceRoots = listOf("src/mingwX64Main/kotlin/pageMerger/Test.kt")
}
val iosArm64 = sourceSet {
- moduleName = "example"
name = "iosArm64"
displayName = "iosArm64"
analysisPlatform = "native"
- dependentSourceSets = setOf(commonN2.sourceSetID)
+ dependentSourceSets = setOf(commonN2.value.sourceSetID)
sourceRoots = listOf("src/iosArm64Main/kotlin/pageMerger/Test.kt")
}
val iosX64 = sourceSet {
- moduleName = "example"
name = "iosX64"
displayName = "iosX64"
analysisPlatform = "native"
- dependentSourceSets = setOf(commonN2.sourceSetID)
+ dependentSourceSets = setOf(commonN2.value.sourceSetID)
sourceRoots = listOf("src/iosX64Main/kotlin/pageMerger/Test.kt")
}
}
@@ -153,30 +144,30 @@ class ExpectActualsTest : AbstractCoreTest() {
) {
pagesTransformationStage = {
val allChildren = it.childrenRec().filterIsInstance<ClasslikePageNode>()
- val commonJ = allChildren.filter { it.name == "A(js, jvm)" }
- val commonN1 = allChildren.filter { it.name == "A(linuxX64, mingwX64)" }
- val commonN2 = allChildren.filter { it.name == "A(iosArm64, iosX64)" }
+ val commonJ = allChildren.filter { it.name == "A(jvm, js)" }
+ val commonN1 = allChildren.filter { it.name == "A(mingwX64, linuxX64)" }
+ val commonN2 = allChildren.filter { it.name == "A(iosX64, iosArm64)" }
val noClass = allChildren.filter { it.name == "A" }
- assertTrue(commonJ.size == 1) { "There can be only one A(js, jvm) page" }
+ assertTrue(commonJ.size == 1) { "There can be only one A(jvm, js) page" }
assertTrue(
commonJ.first().documentable?.sourceSets?.map { it.displayName }
?.containsAll(listOf("commonJ", "js", "jvm")) ?: false
- ) { "A(js, jvm)should have commonJ, js, jvm sources" }
+ ) { "A(jvm, js)should have commonJ, js, jvm sources" }
- assertTrue(commonN1.size == 1) { "There can be only one A(linuxX64, mingwX64) page" }
+ assertTrue(commonN1.size == 1) { "There can be only one A(mingwX64, linuxX64) page" }
assertTrue(
commonN1.first().documentable?.sourceSets?.map { it.displayName }
?.containsAll(listOf("commonN1", "linuxX64", "mingwX64")) ?: false
- ) { "A(linuxX64, mingwX64) should have commonN1, linuxX64, mingwX64 sources" }
+ ) { "A(mingwX64, linuxX64) should have commonN1, linuxX64, mingwX64 sources" }
- assertTrue(commonN2.size == 1) { "There can be only one A(iosArm64, iosX64) page" }
+ assertTrue(commonN2.size == 1) { "There can be only one A(iosX64, iosArm64) page" }
assertTrue(
commonN2.first().documentable?.sourceSets?.map { it.displayName }
?.containsAll(listOf("commonN2", "iosArm64", "iosX64")) ?: false
- ) { "A(iosArm64, iosX64) should have commonN2, iosArm64, iosX64 sources" }
+ ) { "A(iosX64, iosArm64) should have commonN2, iosArm64, iosX64 sources" }
assertTrue(noClass.isEmpty()) { "There can't be any A page" }
}
}
}
-} \ No newline at end of file
+}
diff --git a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt
index 1a57ae02..49fe8d5a 100644
--- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt
+++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt
@@ -129,28 +129,26 @@ class PageNodeMergerTest : AbstractCoreTest() {
fun `should not be merged`() {
val configuration = dokkaConfiguration {
+ moduleName = "example"
sourceSets {
val common = sourceSet {
- moduleName = "example"
name = "common"
displayName = "common"
analysisPlatform = "common"
sourceRoots = listOf("src/commonMain/kotlin/pageMerger/Test.kt")
}
val js = sourceSet {
- moduleName = "example"
name = "js"
displayName = "js"
analysisPlatform = "js"
- dependentSourceSets = setOf(common.sourceSetID)
+ dependentSourceSets = setOf(common.value.sourceSetID)
sourceRoots = listOf("src/jsMain/kotlin/pageMerger/Test.kt")
}
val jvm = sourceSet {
- moduleName = "example"
name = "jvm"
displayName = "jvm"
analysisPlatform = "jvm"
- dependentSourceSets = setOf(common.sourceSetID)
+ dependentSourceSets = setOf(common.value.sourceSetID)
sourceRoots = listOf("src/jvmMain/kotlin/pageMerger/Test.kt")
}
}
diff --git a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
index 975373b6..d72b5c33 100644
--- a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
@@ -58,7 +58,7 @@ class DivergentSignatureTest : AbstractCoreTest() {
val content = writerPlugin.renderedContent("example/example/-clock/get-time.html")
assert(content.count() == 1)
- assert(content.select("[data-filterable-current=example/common example/jvm example/js]").single().brief == "common")
+ assert(content.select("[data-filterable-current=example/common example/js example/jvm]").single().brief == "common")
}
}
}