diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-09-01 10:51:30 +0200 |
---|---|---|
committer | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2020-09-08 12:52:59 +0200 |
commit | 46c56dc71ed2c6d73a70ed4fd8255eeda2420ff4 (patch) | |
tree | 2d5d2a8f6adc2ab6f1ea27be5aef1d86c760fb50 | |
parent | 883408f0d12abfba88434b41cd8d752afc7ebf35 (diff) | |
download | dokka-46c56dc71ed2c6d73a70ed4fd8255eeda2420ff4.tar.gz dokka-46c56dc71ed2c6d73a70ed4fd8255eeda2420ff4.tar.bz2 dokka-46c56dc71ed2c6d73a70ed4fd8255eeda2420ff4.zip |
Remove topologicalSort since it is no longer used
5 files changed, 33 insertions, 76 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 2efaf539..c7338458 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -83,7 +83,7 @@ interface WithIsExpectActual { val isExpectActual: Boolean } -interface Callable : WithVisibility, WithType, WithAbstraction, WithSources { +interface Callable : WithVisibility, WithType, WithAbstraction, WithSources, WithIsExpectActual { val receiver: DParameter? } @@ -150,7 +150,7 @@ data class DClass( override val isExpectActual: Boolean, override val extra: PropertyContainer<DClass> = PropertyContainer.empty() ) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, - WithExtraProperties<DClass>, WithIsExpectActual { + WithExtraProperties<DClass> { override val children: List<Documentable> get() = (functions + properties + classlikes + constructors) @@ -175,7 +175,7 @@ data class DEnum( override val sourceSets: Set<DokkaSourceSet>, override val isExpectActual: Boolean, override val extra: PropertyContainer<DEnum> = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties<DEnum>, WithIsExpectActual { +) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties<DEnum> { override val children: List<Documentable> get() = (entries + functions + properties + classlikes + constructors) @@ -215,7 +215,7 @@ data class DFunction( override val sourceSets: Set<DokkaSourceSet>, override val isExpectActual: Boolean, override val extra: PropertyContainer<DFunction> = PropertyContainer.empty() -) : Documentable(), Callable, WithGenerics, WithExtraProperties<DFunction>, WithIsExpectActual { +) : Documentable(), Callable, WithGenerics, WithExtraProperties<DFunction> { override val children: List<Documentable> get() = parameters @@ -238,7 +238,7 @@ data class DInterface( override val sourceSets: Set<DokkaSourceSet>, override val isExpectActual: Boolean, override val extra: PropertyContainer<DInterface> = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties<DInterface>, WithIsExpectActual { +) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties<DInterface> { override val children: List<Documentable> get() = (functions + properties + classlikes) @@ -259,7 +259,7 @@ data class DObject( override val sourceSets: Set<DokkaSourceSet>, override val isExpectActual: Boolean, override val extra: PropertyContainer<DObject> = PropertyContainer.empty() -) : DClasslike(), WithSupertypes, WithExtraProperties<DObject>, WithIsExpectActual { +) : DClasslike(), WithSupertypes, WithExtraProperties<DObject> { override val children: List<Documentable> get() = (functions + properties + classlikes) @@ -282,7 +282,7 @@ data class DAnnotation( override val sourceSets: Set<DokkaSourceSet>, override val isExpectActual: Boolean, override val extra: PropertyContainer<DAnnotation> = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties<DAnnotation>, WithGenerics, WithIsExpectActual { +) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties<DAnnotation>, WithGenerics { override val children: List<Documentable> get() = (functions + properties + classlikes + constructors) @@ -305,7 +305,7 @@ data class DProperty( override val generics: List<DTypeParameter>, override val isExpectActual: Boolean, override val extra: PropertyContainer<DProperty> = PropertyContainer.empty() -) : Documentable(), Callable, WithExtraProperties<DProperty>, WithGenerics, WithIsExpectActual { +) : Documentable(), Callable, WithExtraProperties<DProperty>, WithGenerics { override val children: List<Nothing> get() = emptyList() 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") } } } |