From fb27b386af878a7cd942e97701b66a0d67f7778c Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Tue, 10 Mar 2020 18:39:19 +0100 Subject: Extract inheritance map --- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 12 ++++++++++-- plugins/base/src/test/kotlin/utils/TestUtils.kt | 14 +++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt index 1e6f64c6..69c4f0d2 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -1,5 +1,6 @@ package utils +import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.model.DModule abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { @@ -9,6 +10,8 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo platform: String = "jvm", targetList: List = listOf("jvm"), prependPackage: Boolean = true, + cleanupOutput: Boolean = true, + pluginsOverrides: List = emptyList(), block: DModule.() -> Unit ) { val configuration = dokkaConfiguration { @@ -20,9 +23,14 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo } } } - val prepend = path.let { p -> p?.let { "|$it\n" } ?: "" } + if(prependPackage) "|package $pkg" else "" + val prepend = path.let { p -> p?.let { "|$it\n" } ?: "" } + if (prependPackage) "|package $pkg" else "" - testInline(("$prepend\n$query").trim().trimIndent(), configuration) { + testInline( + query = ("$prepend\n$query").trim().trimIndent(), + configuration = configuration, + cleanupOutput = cleanupOutput, + pluginOverrides = pluginsOverrides + ) { documentablesTransformationStage = block } } diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index bf86c1b1..68ab7120 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -1,9 +1,9 @@ package utils -import org.jetbrains.dokka.model.DClass -import org.jetbrains.dokka.model.Documentable +import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import kotlin.collections.orEmpty @DslMarker annotation class TestDSL @@ -61,4 +61,12 @@ fun T?.assertNotNull(name: String = ""): T = this ?: throw AssertionError("$ fun T?.docs() = this?.documentation.orEmpty().values.flatMap { it.children } val DClass.supers - get() = supertypes.flatMap{it.component2()} \ No newline at end of file + get() = supertypes.flatMap { it.component2() } + +val Bound.name: String? + get() = when (this) { + is Nullable -> inner.name + is OtherParameter -> name + is PrimitiveJavaType -> name + is TypeConstructor -> dri.classNames + } \ No newline at end of file -- cgit