From cacf1e0c6cda4e42fe6581946cad53a377c71ec7 Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Wed, 26 Feb 2020 11:52:03 +0100 Subject: Port some of the core tests from the previous model --- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 33 ++++++++++++ plugins/base/src/test/kotlin/utils/TestUtils.kt | 68 ++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 plugins/base/src/test/kotlin/utils/ModelUtils.kt create mode 100644 plugins/base/src/test/kotlin/utils/TestUtils.kt (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 new file mode 100644 index 00000000..6893c65f --- /dev/null +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -0,0 +1,33 @@ +package utils + +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.doc.DocumentationNode +import testApi.testRunner.AbstractCoreTest + +abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { + + fun inlineModelTest( + query: String, + platform: String = "jvm", + targetList: List = listOf("jvm"), + prependPackage: Boolean = true, + block: Module.() -> Unit + ) { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + analysisPlatform = platform + targets = targetList + } + } + } + val prepend = path.let { p -> p?.let { "|$it\n" } ?: "" } + if(prependPackage) "|package $pkg" else "" + + testInline(("$prepend\n$query").trim().trimIndent(), configuration) { + documentablesTransformationStage = block + } + } + + +} diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt new file mode 100644 index 00000000..641c68a2 --- /dev/null +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -0,0 +1,68 @@ +package utils + +import org.jetbrains.dokka.model.Class +import org.jetbrains.dokka.model.Documentable +import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.Property +import org.jetbrains.dokka.model.doc.* +import testApi.testRunner.AbstractCoreTest +import kotlin.reflect.KClass +import kotlin.reflect.full.safeCast + +@DslMarker +annotation class TestDSL + +@TestDSL +abstract class ModelDSL : AbstractCoreTest() { + operator fun Documentable?.div(name: String): Documentable? = + this?.children?.find { it.name == name } + + inline fun Documentable?.cast(): T = + (this as? T).assertNotNull() +} + +@TestDSL +interface AssertDSL { + infix fun Any?.equals(other: Any?) = this.assertEqual(other) + infix fun Collection?.allEquals(other: Any?) = + this?.also { c -> c.forEach { it equals other } } ?: run { assert(false) { "Collection is empty" } } + + infix fun Collection?.counts(n: Int) = this.orEmpty().assertCount(n) + + infix fun T?.notNull(name: String): T = this.assertNotNull(name) + + fun Collection.assertCount(n: Int, prefix: String = "") = + assert(count() == n) { "${prefix}Expected $n, got ${count()}" } + + fun T?.assertEqual(expected: T, prefix: String = "") = assert(this == expected) { + "${prefix}Expected $expected, got $this" + } +} + +inline fun Any?.assertIsInstance(name: String): T = + this.let { it as? T } ?: throw AssertionError("$name should not be null") + +fun List.commentsToString(): String = + this.flatMap { it.children }.joinToString(separator = "\n") { it.root.docTagSummary() } + +fun TagWrapper.text(): String = when (val t = this) { + is NamedTagWrapper -> "${t.name}: [${t.root.text()}]" + else -> t.root.text() +} + +fun DocTag.text(): String = when (val t = this) { + is Text -> t.body + is Code -> t.children.joinToString("\n") { it.text() } + is P -> t.children.joinToString(separator = "\n") { it.text() } + else -> t.toString() +} + +fun T?.comments(): String = docs().map { it.text() } + .joinToString(separator = "\n") { it } + +fun T?.assertNotNull(name: String = ""): T = this ?: throw AssertionError("$name should not be null") + +fun T?.docs() = this?.documentation.orEmpty().values.flatMap { it.children } + +val Class.supers + get() = supertypes.flatMap{it.component2()} \ No newline at end of file -- cgit From ac590359174995a16a116a96dbb9df5dafa042f5 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Fri, 28 Feb 2020 16:30:17 +0100 Subject: Test api moved to sensible package --- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 2 +- plugins/base/src/test/kotlin/utils/TestUtils.kt | 2 +- 2 files changed, 2 insertions(+), 2 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 6893c65f..75c8e008 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -2,7 +2,7 @@ package utils import org.jetbrains.dokka.model.Module import org.jetbrains.dokka.model.doc.DocumentationNode -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 641c68a2..6913ba5b 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -5,7 +5,7 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.Function import org.jetbrains.dokka.model.Property import org.jetbrains.dokka.model.doc.* -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import kotlin.reflect.KClass import kotlin.reflect.full.safeCast -- cgit From 763f53987fe803eac412d8549ba2e07ef9560107 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Fri, 28 Feb 2020 13:30:51 +0100 Subject: Output writer for renderer tests --- .../base/src/test/kotlin/utils/TestOutputWriter.kt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/base/src/test/kotlin/utils/TestOutputWriter.kt (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt new file mode 100644 index 00000000..43161929 --- /dev/null +++ b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt @@ -0,0 +1,27 @@ +package utils + +import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.renderers.OutputWriter +import org.jetbrains.dokka.plugability.DokkaPlugin +import java.io.File + +class TestOutputWriterPlugin(failOnOverwrite: Boolean): DokkaPlugin() { + private val writer = TestOutputWriter(failOnOverwrite) + + val testWriter by extending { plugin().outputWriter with writer } +} + +class TestOutputWriter(private val failOnOverwrite: Boolean): OutputWriter { + val contents: Map get() = _contents + + private val _contents = mutableMapOf() + + override fun write(path: String, text: String, ext: String) { + val fullPath = listOf(path, ext).joinToString(separator = ".") + _contents.putIfAbsent(fullPath, text)?.also { + if (failOnOverwrite) throw AssertionError("File $fullPath is being overwritten.") + } + } + + override fun writeResources(pathFrom: String, pathTo: String) = write(pathFrom, File(pathTo).readText(), "") +} -- cgit From 973cc5238e2f7ede6d9cf54437785770a3e020c9 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 2 Mar 2020 17:10:16 +0100 Subject: Tests for wrapping groups in renderer. Also util for groups --- plugins/base/src/test/kotlin/utils/TestOutputWriter.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt index 43161929..e2250a26 100644 --- a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt +++ b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt @@ -5,23 +5,23 @@ import org.jetbrains.dokka.base.renderers.OutputWriter import org.jetbrains.dokka.plugability.DokkaPlugin import java.io.File -class TestOutputWriterPlugin(failOnOverwrite: Boolean): DokkaPlugin() { +class TestOutputWriterPlugin(failOnOverwrite: Boolean = true): DokkaPlugin() { private val writer = TestOutputWriter(failOnOverwrite) val testWriter by extending { plugin().outputWriter with writer } } -class TestOutputWriter(private val failOnOverwrite: Boolean): OutputWriter { +class TestOutputWriter(private val failOnOverwrite: Boolean = true): OutputWriter { val contents: Map get() = _contents private val _contents = mutableMapOf() override fun write(path: String, text: String, ext: String) { - val fullPath = listOf(path, ext).joinToString(separator = ".") + val fullPath = "$path$ext" _contents.putIfAbsent(fullPath, text)?.also { if (failOnOverwrite) throw AssertionError("File $fullPath is being overwritten.") } } - override fun writeResources(pathFrom: String, pathTo: String) = write(pathFrom, File(pathTo).readText(), "") + override fun writeResources(pathFrom: String, pathTo: String) = write(pathTo, "*** content of $pathFrom ***", "") } -- cgit From 996feefe717ac623daabaadda71b5b9d2bbe1cf1 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Mon, 16 Mar 2020 14:33:38 +0100 Subject: Rename Documentables to avoid name conflicts --- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 6 ++---- plugins/base/src/test/kotlin/utils/TestUtils.kt | 8 ++------ 2 files changed, 4 insertions(+), 10 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 75c8e008..1e6f64c6 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -1,8 +1,6 @@ package utils -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.model.DModule abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { @@ -11,7 +9,7 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo platform: String = "jvm", targetList: List = listOf("jvm"), prependPackage: Boolean = true, - block: Module.() -> Unit + block: DModule.() -> Unit ) { val configuration = dokkaConfiguration { passes { diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 6913ba5b..bf86c1b1 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -1,13 +1,9 @@ package utils -import org.jetbrains.dokka.model.Class +import org.jetbrains.dokka.model.DClass import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Property import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest -import kotlin.reflect.KClass -import kotlin.reflect.full.safeCast @DslMarker annotation class TestDSL @@ -64,5 +60,5 @@ fun T?.assertNotNull(name: String = ""): T = this ?: throw AssertionError("$ fun T?.docs() = this?.documentation.orEmpty().values.flatMap { it.children } -val Class.supers +val DClass.supers get() = supertypes.flatMap{it.component2()} \ No newline at end of file -- cgit 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 From 03329b0eb98b309d208839344052633028e00984 Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Wed, 18 Mar 2020 14:19:54 +0100 Subject: Fix minor bugs and add core tests --- plugins/base/src/test/kotlin/utils/TestUtils.kt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 68ab7120..8a3053b3 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -3,6 +3,7 @@ package utils import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions.assertTrue import kotlin.collections.orEmpty @DslMarker @@ -22,6 +23,10 @@ interface AssertDSL { infix fun Any?.equals(other: Any?) = this.assertEqual(other) infix fun Collection?.allEquals(other: Any?) = this?.also { c -> c.forEach { it equals other } } ?: run { assert(false) { "Collection is empty" } } + infix fun Collection?.exists(e: T) { + assertTrue(this.orEmpty().isNotEmpty(), "Collection cannot be null or empty") + assertTrue(this!!.any{it == e}, "Collection doesn't contain $e") + } infix fun Collection?.counts(n: Int) = this.orEmpty().assertCount(n) -- cgit From 3f8fef0f65fe96fb2a3b1dc2280a16b175fbb6c9 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 24 Mar 2020 16:19:51 +0100 Subject: Fix stdlib tests by adding stdlib to the test classpath --- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 10 +++++----- 1 file changed, 5 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 69c4f0d2..f65258b1 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -1,7 +1,8 @@ package utils -import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.model.DModule +import org.jetbrains.dokka.plugability.DokkaPlugin abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { @@ -12,9 +13,10 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo prependPackage: Boolean = true, cleanupOutput: Boolean = true, pluginsOverrides: List = emptyList(), + configuration: DokkaConfigurationImpl? = null, block: DModule.() -> Unit ) { - val configuration = dokkaConfiguration { + val testConfiguration = configuration ?: dokkaConfiguration { passes { pass { sourceRoots = listOf("src/") @@ -27,13 +29,11 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo testInline( query = ("$prepend\n$query").trim().trimIndent(), - configuration = configuration, + configuration = testConfiguration, cleanupOutput = cleanupOutput, pluginOverrides = pluginsOverrides ) { documentablesTransformationStage = block } } - - } -- cgit From 40c3650b2e51d06a10ba204c79ca5c94d390a513 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 25 Mar 2020 15:51:51 +0100 Subject: Introduce VoidObject and JavaObject --- plugins/base/src/test/kotlin/utils/TestUtils.kt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 8a3053b3..41c245e6 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -74,4 +74,6 @@ val Bound.name: String? is OtherParameter -> name is PrimitiveJavaType -> name is TypeConstructor -> dri.classNames + is JavaObject -> "Object" + is Void -> "void" } \ No newline at end of file -- cgit From 810f3c922fb4f11dc3fbdddee82d919189ed8526 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Thu, 26 Mar 2020 13:17:38 +0100 Subject: Adds simple tests for parameter rendering --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 plugins/base/src/test/kotlin/utils/contentUtils.kt (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt new file mode 100644 index 00000000..4bb36553 --- /dev/null +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -0,0 +1,56 @@ +package utils + +import matchers.content.* + +//TODO: Try to unify those functions after update to 1.4 +fun ContentMatcherBuilder<*>.signature( + name: String, + returnType: String? = null, + vararg params: Pair +) = + platformHinted { + group { // TODO: remove it when double wrapping for signatures will be resolved + +"final fun" + link { +name } + +"(" + params.forEachIndexed { id, (n, t) -> + +"$n:" + group { link { +t } } + if (id != params.lastIndex) + +", " + } + +")" + returnType?.let { +": $it" } + } + } + +fun ContentMatcherBuilder<*>.signatureWithReceiver( + receiver: String, + name: String, + returnType: String? = null, + vararg params: Pair +) = + platformHinted { + group { // TODO: remove it when double wrapping for signatures will be resolved + +"final fun" + group { + link { +receiver } + } + +"." + link { +name } + +"(" + params.forEach { (n, t) -> + +"$n:" + group { link { +t } } + } + +")" + returnType?.let { +": $it" } + } + } + + +fun ContentMatcherBuilder<*>.pWrapped(text: String) = + group {// TODO: remove it when double wrapping for descriptions will be resolved + group { +text } + br() + } \ No newline at end of file -- cgit From 6fec129cc61bd2a54f9d1111057c650430426013 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Tue, 31 Mar 2020 08:39:01 +0200 Subject: Make PageContentBuilder to create proper content for all tags --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 4bb36553..1e19058a 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -1,6 +1,7 @@ package utils import matchers.content.* +import org.jetbrains.dokka.pages.ContentGroup //TODO: Try to unify those functions after update to 1.4 fun ContentMatcherBuilder<*>.signature( @@ -53,4 +54,10 @@ fun ContentMatcherBuilder<*>.pWrapped(text: String) = group {// TODO: remove it when double wrapping for descriptions will be resolved group { +text } br() + } + +fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuilder.() -> Unit) = + group { + header(4) { +tag } + group { content() } } \ No newline at end of file -- cgit From 83ba2aa4a885bf9ab07ca0402fb8bcf1ca1547ad Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 8 Apr 2020 12:53:32 +0200 Subject: Fix content tests --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 1e19058a..8742e91a 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -53,7 +53,6 @@ fun ContentMatcherBuilder<*>.signatureWithReceiver( fun ContentMatcherBuilder<*>.pWrapped(text: String) = group {// TODO: remove it when double wrapping for descriptions will be resolved group { +text } - br() } fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuilder.() -> Unit) = -- cgit From 720c50fb7f4bf4ae4b4d4c406cfb958a7fba8ffb Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Mon, 6 Apr 2020 15:58:55 +0200 Subject: Adds asynchronous rendering --- plugins/base/src/test/kotlin/utils/TestOutputWriter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt index e2250a26..607d3ced 100644 --- a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt +++ b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt @@ -16,12 +16,12 @@ class TestOutputWriter(private val failOnOverwrite: Boolean = true): OutputWrite private val _contents = mutableMapOf() - override fun write(path: String, text: String, ext: String) { + override suspend fun write(path: String, text: String, ext: String) { val fullPath = "$path$ext" _contents.putIfAbsent(fullPath, text)?.also { if (failOnOverwrite) throw AssertionError("File $fullPath is being overwritten.") } } - override fun writeResources(pathFrom: String, pathTo: String) = write(pathTo, "*** content of $pathFrom ***", "") + override suspend fun writeResources(pathFrom: String, pathTo: String) = write(pathTo, "*** content of $pathFrom ***", "") } -- cgit From 65e69a8d204f873a4034810436649c3f02de3ad0 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 14 May 2020 17:47:39 +0200 Subject: Divergent UI fixes --- plugins/base/src/test/kotlin/utils/TestUtils.kt | 3 --- 1 file changed, 3 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 41c245e6..6bc624d6 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -43,9 +43,6 @@ interface AssertDSL { inline fun Any?.assertIsInstance(name: String): T = this.let { it as? T } ?: throw AssertionError("$name should not be null") -fun List.commentsToString(): String = - this.flatMap { it.children }.joinToString(separator = "\n") { it.root.docTagSummary() } - fun TagWrapper.text(): String = when (val t = this) { is NamedTagWrapper -> "${t.name}: [${t.root.text()}]" else -> t.root.text() -- cgit From 5451627eb0cf8d95dafd23e96665e062ef023d75 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Mon, 18 May 2020 17:14:23 +0200 Subject: Add test utils for ContentDivergent and fix the tests --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 68 +++++++++++++--------- 1 file changed, 41 insertions(+), 27 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 8742e91a..c71409c3 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -10,20 +10,26 @@ fun ContentMatcherBuilder<*>.signature( vararg params: Pair ) = platformHinted { - group { // TODO: remove it when double wrapping for signatures will be resolved - +"final fun" - link { +name } - +"(" - params.forEachIndexed { id, (n, t) -> - +"$n:" - group { link { +t } } - if (id != params.lastIndex) - +", " - } - +")" - returnType?.let { +": $it" } - } + bareSignature(name, returnType, *params) + } + +fun ContentMatcherBuilder<*>.bareSignature( + name: String, + returnType: String? = null, + vararg params: Pair +) = group { + +"final fun" + link { +name } + +"(" + params.forEachIndexed { id, (n, t) -> + +"$n:" + group { link { +t } } + if (id != params.lastIndex) + +", " } + +")" + returnType?.let { +": $it" } +} fun ContentMatcherBuilder<*>.signatureWithReceiver( receiver: String, @@ -32,21 +38,29 @@ fun ContentMatcherBuilder<*>.signatureWithReceiver( vararg params: Pair ) = platformHinted { - group { // TODO: remove it when double wrapping for signatures will be resolved - +"final fun" - group { - link { +receiver } - } - +"." - link { +name } - +"(" - params.forEach { (n, t) -> - +"$n:" - group { link { +t } } - } - +")" - returnType?.let { +": $it" } + bareSignatureWithReceiver(receiver, name, returnType, *params) + } + +fun ContentMatcherBuilder<*>.bareSignatureWithReceiver( + receiver: String, + name: String, + returnType: String? = null, + vararg params: Pair +) = + group { + +"final fun" + group { + link { +receiver } + } + +"." + link { +name } + +"(" + params.forEach { (n, t) -> + +"$n:" + group { link { +t } } } + +")" + returnType?.let { +": $it" } } -- cgit From d47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Mon, 4 May 2020 13:53:10 +0200 Subject: Enhance signature presentation. Support presetnation Java as Kotlin and Kotlin as Java. Refactor annotations creation from PSI/Descriptors. Add proper rendering of annotation signatures in both kotlin syntax and java syntax. Tests for annotations --- plugins/base/src/test/kotlin/utils/TestUtils.kt | 1 + plugins/base/src/test/kotlin/utils/contentUtils.kt | 173 ++++++++++++++++++--- 2 files changed, 149 insertions(+), 25 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 6bc624d6..1591f4f7 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -73,4 +73,5 @@ val Bound.name: String? is TypeConstructor -> dri.classNames is JavaObject -> "Object" is Void -> "void" + is Dynamic -> "dynamic" } \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index c71409c3..a1141832 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -1,68 +1,174 @@ package utils import matchers.content.* +import org.jetbrains.dokka.model.* import org.jetbrains.dokka.pages.ContentGroup +import kotlin.text.Typography.nbsp //TODO: Try to unify those functions after update to 1.4 -fun ContentMatcherBuilder<*>.signature( +fun ContentMatcherBuilder<*>.functionSignature( + annotations: Map>, + visibility: String, + modifier: String, + keywords: Set, name: String, returnType: String? = null, - vararg params: Pair + vararg params: Pair ) = platformHinted { - bareSignature(name, returnType, *params) + bareSignature(annotations, visibility, modifier, keywords, name, returnType, *params) } fun ContentMatcherBuilder<*>.bareSignature( + annotations: Map>, + visibility: String, + modifier: String, + keywords: Set, name: String, returnType: String? = null, - vararg params: Pair -) = group { - +"final fun" - link { +name } - +"(" - params.forEachIndexed { id, (n, t) -> - +"$n:" - group { link { +t } } - if (id != params.lastIndex) - +", " + vararg params: Pair +) = group { // TODO: remove it when double wrapping for signatures will be resolved + group { + annotations.entries.forEach { + group { + unwrapAnnotation(it) + } + } + +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun") + link { +name } + +"(" + params.forEachIndexed { id, (n, t) -> + + t.annotations.forEach { + unwrapAnnotation(it) + } + t.keywords.forEach { + +it + } + + +"$n:" + group { link { +(t.type) } } + if (id != params.lastIndex) + +", " + } + +")" + if (returnType != null) { + +(": ") + group { + link { + +(returnType) + } + } + } } - +")" - returnType?.let { +": $it" } } -fun ContentMatcherBuilder<*>.signatureWithReceiver( +fun ContentMatcherBuilder<*>.functionSignatureWithReceiver( + annotations: Map>, + visibility: String?, + modifier: String?, + keywords: Set, receiver: String, name: String, returnType: String? = null, - vararg params: Pair + vararg params: Pair ) = platformHinted { - bareSignatureWithReceiver(receiver, name, returnType, *params) + bareSignatureWithReceiver(annotations, visibility, modifier, keywords, receiver, name, returnType, *params) } fun ContentMatcherBuilder<*>.bareSignatureWithReceiver( + annotations: Map>, + visibility: String?, + modifier: String?, + keywords: Set, receiver: String, name: String, returnType: String? = null, - vararg params: Pair -) = + vararg params: Pair +) = group { // TODO: remove it when double wrapping for signatures will be resolved group { - +"final fun" + annotations.entries.forEach { + group { + unwrapAnnotation(it) + } + } + +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun") group { link { +receiver } } +"." link { +name } +"(" - params.forEach { (n, t) -> + params.forEachIndexed { id, (n, t) -> + + t.annotations.forEach { + unwrapAnnotation(it) + } + t.keywords.forEach { + +it + } + +"$n:" - group { link { +t } } + group { link { +(t.type) } } + if (id != params.lastIndex) + +", " } +")" - returnType?.let { +": $it" } + if (returnType != null) { + +(": ") + group { + link { + +(returnType) + } + } + } } +} +fun ContentMatcherBuilder<*>.propertySignature( + annotations: Map>, + visibility: String, + modifier: String, + keywords: Set, + preposition: String, + name: String, + type: String? = null +) { + group { + header { +"Package test" } + } + group { + skipAllNotMatching() + header { +"Properties" } + table { + group { + link { +name } + platformHinted { + group { + group { + annotations.entries.forEach { + group { + unwrapAnnotation(it) + } + } + +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition") + link { +name } + if (type != null) { + +(": ") + group { + link { + +(type) + } + } + } + } + } + } + } + } + } +} fun ContentMatcherBuilder<*>.pWrapped(text: String) = group {// TODO: remove it when double wrapping for descriptions will be resolved @@ -73,4 +179,21 @@ fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuil group { header(4) { +tag } group { content() } - } \ No newline at end of file + } + +private fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { + +"@" + link { +elem.key } + +"(" + elem.value.forEach { + +("$it = ") + skipAllNotMatching() + } + +")" +} + +data class ParamAttributes( + val annotations: Map>, + val keywords: Set, + val type: String +) \ No newline at end of file -- cgit From 77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Thu, 21 May 2020 11:29:22 +0200 Subject: Apply request changes --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index a1141832..ec119ebb 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -139,26 +139,28 @@ fun ContentMatcherBuilder<*>.propertySignature( header { +"Package test" } } group { - skipAllNotMatching() - header { +"Properties" } - table { - group { - link { +name } - platformHinted { - group { + group { + skipAllNotMatching() + header { +"Properties" } + table { + group { + link { +name } + platformHinted { group { - annotations.entries.forEach { - group { - unwrapAnnotation(it) + group { + annotations.entries.forEach { + group { + unwrapAnnotation(it) + } } - } - +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition") - link { +name } - if (type != null) { - +(": ") - group { - link { - +(type) + +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition") + link { +name } + if (type != null) { + +(": ") + group { + link { + +(type) + } } } } -- cgit From 0caf8dc94722962e0d2719399eae3a6b75574f6f Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Fri, 22 May 2020 17:22:51 +0200 Subject: Light annotations fix --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index ec119ebb..4aba3e9d 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -137,6 +137,7 @@ fun ContentMatcherBuilder<*>.propertySignature( ) { group { header { +"Package test" } + skipAllNotMatching() } group { group { -- cgit From f0742fb7f8a937ef7c2e5a92d6f4a0fd079baa62 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Mon, 25 May 2020 14:40:59 +0200 Subject: Enum constructor values --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 4aba3e9d..7e1b8bf4 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -184,7 +184,7 @@ fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuil group { content() } } -private fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { +fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { +"@" link { +elem.key } +"(" -- cgit From 7674ce23f132f727b71545ad3aa62be5059613d6 Mon Sep 17 00:00:00 2001 From: Filip Zybała Date: Wed, 3 Jun 2020 14:43:27 +0200 Subject: Fixed problem with linking absolute links as relative --- plugins/base/src/test/kotlin/utils/TestOutputWriter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt index 607d3ced..46ada43a 100644 --- a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt +++ b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt @@ -6,7 +6,7 @@ import org.jetbrains.dokka.plugability.DokkaPlugin import java.io.File class TestOutputWriterPlugin(failOnOverwrite: Boolean = true): DokkaPlugin() { - private val writer = TestOutputWriter(failOnOverwrite) + val writer = TestOutputWriter(failOnOverwrite) val testWriter by extending { plugin().outputWriter with writer } } -- cgit From dd44b839eac1b7b647e97f2cc73dd96bd054713b Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Thu, 28 May 2020 21:12:50 +0200 Subject: Refactor of Annotations and ExtraModifiers to be platform depedent --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 154 ++++++++++----------- 1 file changed, 76 insertions(+), 78 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 7e1b8bf4..c7cea1f1 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -28,36 +28,34 @@ fun ContentMatcherBuilder<*>.bareSignature( returnType: String? = null, vararg params: Pair ) = group { // TODO: remove it when double wrapping for signatures will be resolved - group { - annotations.entries.forEach { - group { - unwrapAnnotation(it) - } + annotations.entries.forEach { + group { + unwrapAnnotation(it) } - +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun") - link { +name } - +"(" - params.forEachIndexed { id, (n, t) -> - - t.annotations.forEach { - unwrapAnnotation(it) - } - t.keywords.forEach { - +it - } + } + +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun") + link { +name } + +"(" + params.forEachIndexed { id, (n, t) -> - +"$n:" - group { link { +(t.type) } } - if (id != params.lastIndex) - +", " + t.annotations.forEach { + unwrapAnnotation(it) } - +")" - if (returnType != null) { - +(": ") - group { - link { - +(returnType) - } + t.keywords.forEach { + +it + } + + +"$n:" + group { link { +(t.type) } } + if (id != params.lastIndex) + +", " + } + +")" + if (returnType != null) { + +(": ") + group { + link { + +(returnType) } } } @@ -87,40 +85,38 @@ fun ContentMatcherBuilder<*>.bareSignatureWithReceiver( returnType: String? = null, vararg params: Pair ) = group { // TODO: remove it when double wrapping for signatures will be resolved - group { - annotations.entries.forEach { - group { - unwrapAnnotation(it) - } - } - +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun") + annotations.entries.forEach { group { - link { +receiver } + unwrapAnnotation(it) } - +"." - link { +name } - +"(" - params.forEachIndexed { id, (n, t) -> - - t.annotations.forEach { - unwrapAnnotation(it) - } - t.keywords.forEach { - +it - } + } + +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun") + group { + link { +receiver } + } + +"." + link { +name } + +"(" + params.forEachIndexed { id, (n, t) -> - +"$n:" - group { link { +(t.type) } } - if (id != params.lastIndex) - +", " + t.annotations.forEach { + unwrapAnnotation(it) } - +")" - if (returnType != null) { - +(": ") - group { - link { - +(returnType) - } + t.keywords.forEach { + +it + } + + +"$n:" + group { link { +(t.type) } } + if (id != params.lastIndex) + +", " + } + +")" + if (returnType != null) { + +(": ") + group { + link { + +(returnType) } } } @@ -148,20 +144,18 @@ fun ContentMatcherBuilder<*>.propertySignature( link { +name } platformHinted { group { - group { - annotations.entries.forEach { - group { - unwrapAnnotation(it) - } + annotations.entries.forEach { + group { + unwrapAnnotation(it) } - +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition") - link { +name } - if (type != null) { - +(": ") - group { - link { - +(type) - } + } + +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition") + link { +name } + if (type != null) { + +(": ") + group { + link { + +(type) } } } @@ -184,15 +178,19 @@ fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuil group { content() } } -fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { - +"@" - link { +elem.key } - +"(" - elem.value.forEach { - +("$it = ") - skipAllNotMatching() +private fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { + group { + +"@" + link { +elem.key } + +"(" + elem.value.forEach { + group { + +("$it = ") + skipAllNotMatching() + } + } + +")" } - +")" } data class ParamAttributes( -- cgit From cf5b1aff6e7bb51414f80ff71f8d2feeb9e5fb9f Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Mon, 8 Jun 2020 11:34:15 +0200 Subject: Fix after rebase --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index c7cea1f1..37f7881b 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -178,7 +178,7 @@ fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuil group { content() } } -private fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { +fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { group { +"@" link { +elem.key } -- cgit From f3baf10b4c882230d382bfcdd94163d070bd0e25 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 20 May 2020 12:05:26 +0200 Subject: Rework dokka configuration and Gradle plugin --- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 2 -- 1 file changed, 2 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 f65258b1..9697a843 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -9,7 +9,6 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo fun inlineModelTest( query: String, platform: String = "jvm", - targetList: List = listOf("jvm"), prependPackage: Boolean = true, cleanupOutput: Boolean = true, pluginsOverrides: List = emptyList(), @@ -21,7 +20,6 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo pass { sourceRoots = listOf("src/") analysisPlatform = platform - targets = targetList } } } -- cgit From cabb4ae863ae41799ef8c11c5a2a1ef7fc34d22b Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 17 Jun 2020 13:48:01 +0200 Subject: Add UnresolvedBound instead of throwing an exception --- plugins/base/src/test/kotlin/utils/TestUtils.kt | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 1591f4f7..44c23e96 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -74,4 +74,5 @@ val Bound.name: String? is JavaObject -> "Object" is Void -> "void" is Dynamic -> "dynamic" + is UnresolvedBound -> "" } \ No newline at end of file -- cgit From 0b0650079ad5df7965e929cfadc0abe95882c7a9 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Tue, 23 Jun 2020 10:50:36 +0200 Subject: Fix tests after rebase --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 37f7881b..90813cf8 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -27,7 +27,7 @@ fun ContentMatcherBuilder<*>.bareSignature( name: String, returnType: String? = null, vararg params: Pair -) = group { // TODO: remove it when double wrapping for signatures will be resolved +) = group { annotations.entries.forEach { group { unwrapAnnotation(it) -- cgit From ae8b4481b56d6bac4a3feb6a427e77afdbe36b2f Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Fri, 26 Jun 2020 17:01:48 +0200 Subject: Show fully qualified name for typealias targets to different packages --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 90813cf8..7fcd8e89 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -167,6 +167,49 @@ fun ContentMatcherBuilder<*>.propertySignature( } } + +fun ContentMatcherBuilder<*>.typealiasSignature(name: String, expressionTarget: String) { + group { + header { +"Package test" } + skipAllNotMatching() + } + group { + group { + skipAllNotMatching() + header { +"Types" } + table { + group { + link { +name } + divergentGroup { + divergentInstance { + group { + group { + group { + group { + +"typealias " + group { + link { +name } + skipAllNotMatching() + } + +" = " + group { + link { +expressionTarget } + } + } + } + } + } + } + skipAllNotMatching() + } + } + skipAllNotMatching() + } + skipAllNotMatching() + } + } +} + fun ContentMatcherBuilder<*>.pWrapped(text: String) = group {// TODO: remove it when double wrapping for descriptions will be resolved group { +text } @@ -197,4 +240,4 @@ data class ParamAttributes( val annotations: Map>, val keywords: Set, val type: String -) \ No newline at end of file +) -- cgit From b0e8622f374f6499058b0f083367b4a54512b702 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Tue, 30 Jun 2020 23:06:03 +0200 Subject: Enforce workspace unique SourceSetID --- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 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 9697a843..87a9c802 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -16,8 +16,8 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo block: DModule.() -> Unit ) { val testConfiguration = configuration ?: dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = platform } -- cgit From 0533ef9a56ae34138a3f8a5e996805713c48c384 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Wed, 1 Jul 2020 17:36:50 +0200 Subject: Add overrides to provided plugins --- plugins/base/src/test/kotlin/utils/TestOutputWriter.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt index 46ada43a..83f1d180 100644 --- a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt +++ b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt @@ -3,15 +3,20 @@ package utils import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.OutputWriter import org.jetbrains.dokka.plugability.DokkaPlugin -import java.io.File -class TestOutputWriterPlugin(failOnOverwrite: Boolean = true): DokkaPlugin() { +class TestOutputWriterPlugin(failOnOverwrite: Boolean = true) : DokkaPlugin() { val writer = TestOutputWriter(failOnOverwrite) - val testWriter by extending { plugin().outputWriter with writer } + private val dokkaBase by lazy { plugin() } + + val testWriter by extending { + (dokkaBase.outputWriter + with writer + override dokkaBase.fileWriter) + } } -class TestOutputWriter(private val failOnOverwrite: Boolean = true): OutputWriter { +class TestOutputWriter(private val failOnOverwrite: Boolean = true) : OutputWriter { val contents: Map get() = _contents private val _contents = mutableMapOf() @@ -23,5 +28,6 @@ class TestOutputWriter(private val failOnOverwrite: Boolean = true): OutputWrite } } - override suspend fun writeResources(pathFrom: String, pathTo: String) = write(pathTo, "*** content of $pathFrom ***", "") + override suspend fun writeResources(pathFrom: String, pathTo: String) = + write(pathTo, "*** content of $pathFrom ***", "") } -- cgit From 9e8455d8a5285bfbdd92cab1515270f695a9b5d3 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 6 Jul 2020 10:08:43 +0200 Subject: Make Location provider use anchor hints --- plugins/base/src/test/kotlin/utils/TestOutputWriter.kt | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt index 83f1d180..00b865b4 100644 --- a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt +++ b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt @@ -20,7 +20,6 @@ class TestOutputWriter(private val failOnOverwrite: Boolean = true) : OutputWrit val contents: Map get() = _contents private val _contents = mutableMapOf() - override suspend fun write(path: String, text: String, ext: String) { val fullPath = "$path$ext" _contents.putIfAbsent(fullPath, text)?.also { -- cgit From 6d1e25756c3e8c43ce4d5721e7665f439a19e47c Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Wed, 8 Jul 2020 10:33:26 +0200 Subject: Move common base test utils to submodule --- .../base/src/test/kotlin/utils/TestOutputWriter.kt | 32 ---------------------- 1 file changed, 32 deletions(-) delete mode 100644 plugins/base/src/test/kotlin/utils/TestOutputWriter.kt (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt b/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt deleted file mode 100644 index 00b865b4..00000000 --- a/plugins/base/src/test/kotlin/utils/TestOutputWriter.kt +++ /dev/null @@ -1,32 +0,0 @@ -package utils - -import org.jetbrains.dokka.base.DokkaBase -import org.jetbrains.dokka.base.renderers.OutputWriter -import org.jetbrains.dokka.plugability.DokkaPlugin - -class TestOutputWriterPlugin(failOnOverwrite: Boolean = true) : DokkaPlugin() { - val writer = TestOutputWriter(failOnOverwrite) - - private val dokkaBase by lazy { plugin() } - - val testWriter by extending { - (dokkaBase.outputWriter - with writer - override dokkaBase.fileWriter) - } -} - -class TestOutputWriter(private val failOnOverwrite: Boolean = true) : OutputWriter { - val contents: Map get() = _contents - - private val _contents = mutableMapOf() - override suspend fun write(path: String, text: String, ext: String) { - val fullPath = "$path$ext" - _contents.putIfAbsent(fullPath, text)?.also { - if (failOnOverwrite) throw AssertionError("File $fullPath is being overwritten.") - } - } - - override suspend fun writeResources(pathFrom: String, pathTo: String) = - write(pathTo, "*** content of $pathFrom ***", "") -} -- cgit From 2ab810271d2b2dba7448a8cb2b53f0031e6ef40e Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Fri, 3 Jul 2020 16:52:56 +0200 Subject: Add tests for signatures rendering --- plugins/base/src/test/kotlin/utils/JsoupUtils.kt | 29 ++++++++++++++++++++++++ plugins/base/src/test/kotlin/utils/TestUtils.kt | 1 + 2 files changed, 30 insertions(+) create mode 100644 plugins/base/src/test/kotlin/utils/JsoupUtils.kt (limited to 'plugins/base/src/test/kotlin/utils') diff --git a/plugins/base/src/test/kotlin/utils/JsoupUtils.kt b/plugins/base/src/test/kotlin/utils/JsoupUtils.kt new file mode 100644 index 00000000..e8c7838d --- /dev/null +++ b/plugins/base/src/test/kotlin/utils/JsoupUtils.kt @@ -0,0 +1,29 @@ +package utils + +import org.jsoup.nodes.Element +import org.jsoup.nodes.Node +import org.jsoup.nodes.TextNode + +fun Element.match(vararg matchers: Any): Unit = + childNodes() + .filter { it !is TextNode || it.text().isNotBlank() } + .let { it.drop(it.size - matchers.size) } + .zip(matchers) + .forEach { (n, m) -> m.accepts(n) } + +open class Tag(val name: String, vararg val matchers: Any) +class Div(vararg matchers: Any) : Tag("div", *matchers) +class P(vararg matchers: Any) : Tag("p", *matchers) +class Span(vararg matchers: Any) : Tag("span", *matchers) +class A(vararg matchers: Any) : Tag("a", *matchers) +object Wbr : Tag("wbr") +private fun Any.accepts(n: Node) { + when (this) { + is String -> assert(n is TextNode && n.text().trim() == this.trim()) { "\"$this\" expected but found: $n" } + is Tag -> { + assert(n is Element && n.tagName() == name) { "Tag $name expected but found: $n" } + if (n is Element && matchers.isNotEmpty()) n.match(*matchers) + } + else -> throw IllegalArgumentException("$this is not proper matcher") + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 44c23e96..bd0e1fe2 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -2,6 +2,7 @@ package utils import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.doc.* +import org.jetbrains.dokka.model.doc.P import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Assertions.assertTrue import kotlin.collections.orEmpty -- cgit