aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/utils
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2023-10-10 12:36:34 +0300
committerGitHub <noreply@github.com>2023-10-10 12:36:34 +0300
commit562a5951ca942c0bd26d839f2ebf509b43ca3c59 (patch)
treeba9dc75e93dc7d95c9114072946389e86f35f220 /plugins/base/src/test/kotlin/utils
parent7503402e8b9c885ecaf27a927b66d327aea5bb14 (diff)
downloaddokka-562a5951ca942c0bd26d839f2ebf509b43ca3c59.tar.gz
dokka-562a5951ca942c0bd26d839f2ebf509b43ca3c59.tar.bz2
dokka-562a5951ca942c0bd26d839f2ebf509b43ca3c59.zip
[K2] Display enum entry members (#3180)
Diffstat (limited to 'plugins/base/src/test/kotlin/utils')
-rw-r--r--plugins/base/src/test/kotlin/utils/contentUtils.kt25
1 files changed, 21 insertions, 4 deletions
diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt
index b83d8697..3ca0bd2d 100644
--- a/plugins/base/src/test/kotlin/utils/contentUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt
@@ -5,10 +5,9 @@
package utils
import matchers.content.*
-import org.jetbrains.dokka.pages.BasicTabbedContentType
-import org.jetbrains.dokka.pages.ContentGroup
-import org.jetbrains.dokka.pages.ContentPage
-import org.jetbrains.dokka.pages.RootPageNode
+import org.jetbrains.dokka.model.dfs
+import org.jetbrains.dokka.pages.*
+import kotlin.test.assertEquals
//TODO: Try to unify those functions after update to 1.4
fun ContentMatcherBuilder<*>.functionSignature(
@@ -327,6 +326,24 @@ fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry<String, Set<String
}
}
}
+inline fun<reified T> PageNode.contentPage(name: String, block: T.() -> Unit) {
+ (dfs { it.name == name } as? T).assertNotNull("The page `$name` is not found").block()
+}
+
+fun ClasslikePageNode.assertHasFunctions(vararg expectedFunctionName: String) {
+ val functions = this.findSectionWithName("Functions").assertNotNull("Functions")
+ val functionsName = functions.children.map { (it.dfs { it is ContentText } as ContentText).text }
+ assertEquals(expectedFunctionName.toList(), functionsName)
+}
+
+fun ClasslikePageNode.findSectionWithName(name: String) : ContentNode? {
+ var sectionHeader: ContentHeader? = null
+ return content.dfs { node ->
+ node.children.filterIsInstance<ContentHeader>().any { header ->
+ header.children.firstOrNull { it is ContentText && it.text == name }?.also { sectionHeader = header } != null
+ }
+ }?.children?.dropWhile { child -> child != sectionHeader }?.drop(1)?.firstOrNull()
+}
data class ParamAttributes(
val annotations: Map<String, Set<String>>,