aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/utils/contentUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin/utils/contentUtils.kt')
-rw-r--r--plugins/base/src/test/kotlin/utils/contentUtils.kt54
1 files changed, 52 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt
index 9f024c5b..d38af3f4 100644
--- a/plugins/base/src/test/kotlin/utils/contentUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt
@@ -1,9 +1,9 @@
package utils
import matchers.content.*
-import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.pages.ContentGroup
-import kotlin.text.Typography.nbsp
+import org.jetbrains.dokka.pages.ContentPage
+import org.jetbrains.dokka.pages.RootPageNode
//TODO: Try to unify those functions after update to 1.4
fun ContentMatcherBuilder<*>.functionSignature(
@@ -68,6 +68,53 @@ fun ContentMatcherBuilder<*>.bareSignature(
}
}
+fun ContentMatcherBuilder<*>.classSignature(
+ annotations: Map<String, Set<String>>,
+ visibility: String,
+ modifier: String,
+ keywords: Set<String>,
+ name: String,
+ vararg params: Pair<String, ParamAttributes>,
+ parent: String? = null
+) = group {
+ annotations.entries.forEach {
+ group {
+ unwrapAnnotation(it)
+ }
+ }
+ if (visibility.isNotBlank()) +"$visibility "
+ if (modifier.isNotBlank()) +"$modifier "
+ +("${keywords.joinToString("") { "$it " }}class ")
+ link { +name }
+ if (params.isNotEmpty()) {
+ +"("
+ group {
+ params.forEachIndexed { id, (n, t) ->
+ group {
+ t.annotations.forEach {
+ unwrapAnnotation(it)
+ }
+ t.keywords.forEach {
+ +it
+ }
+
+ +"$n: "
+ group { link { +(t.type) } }
+ if (id != params.lastIndex)
+ +", "
+ }
+ }
+ }
+ +")"
+ }
+ if (parent != null) {
+ +(" : ")
+ link {
+ +(parent)
+ }
+ }
+}
+
fun ContentMatcherBuilder<*>.functionSignatureWithReceiver(
annotations: Map<String, Set<String>>,
visibility: String?,
@@ -272,3 +319,6 @@ data class ParamAttributes(
val keywords: Set<String>,
val type: String
)
+
+fun RootPageNode.findTestType(packageName: String, name: String) =
+ children.single { it.name == packageName }.children.single { it.name == name } as ContentPage \ No newline at end of file