diff options
Diffstat (limited to 'plugins/base/src/test/kotlin/utils')
-rw-r--r-- | plugins/base/src/test/kotlin/utils/TestUtils.kt | 1 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/utils/contentUtils.kt | 173 |
2 files changed, 149 insertions, 25 deletions
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<String, Set<String>>, + visibility: String, + modifier: String, + keywords: Set<String>, name: String, returnType: String? = null, - vararg params: Pair<String, String> + vararg params: Pair<String, ParamAttributes> ) = platformHinted { - bareSignature(name, returnType, *params) + bareSignature(annotations, visibility, modifier, keywords, name, returnType, *params) } fun ContentMatcherBuilder<*>.bareSignature( + annotations: Map<String, Set<String>>, + visibility: String, + modifier: String, + keywords: Set<String>, name: String, returnType: String? = null, - vararg params: Pair<String, String> -) = group { - +"final fun" - link { +name } - +"(" - params.forEachIndexed { id, (n, t) -> - +"$n:" - group { link { +t } } - if (id != params.lastIndex) - +", " + vararg params: Pair<String, ParamAttributes> +) = 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<String, Set<String>>, + visibility: String?, + modifier: String?, + keywords: Set<String>, receiver: String, name: String, returnType: String? = null, - vararg params: Pair<String, String> + vararg params: Pair<String, ParamAttributes> ) = platformHinted { - bareSignatureWithReceiver(receiver, name, returnType, *params) + bareSignatureWithReceiver(annotations, visibility, modifier, keywords, receiver, name, returnType, *params) } fun ContentMatcherBuilder<*>.bareSignatureWithReceiver( + annotations: Map<String, Set<String>>, + visibility: String?, + modifier: String?, + keywords: Set<String>, receiver: String, name: String, returnType: String? = null, - vararg params: Pair<String, String> -) = + vararg params: Pair<String, ParamAttributes> +) = 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<String, Set<String>>, + visibility: String, + modifier: String, + keywords: Set<String>, + 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<String, Set<String>>) { + +"@" + link { +elem.key } + +"(" + elem.value.forEach { + +("$it = ") + skipAllNotMatching() + } + +")" +} + +data class ParamAttributes( + val annotations: Map<String, Set<String>>, + val keywords: Set<String>, + val type: String +)
\ No newline at end of file |