From 1aba0ec4973d7915caa93f1e9b3146ad82111903 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Fri, 30 Oct 2020 19:01:09 +0100 Subject: Fix parsing first word in deprecated (#1595) Fix parsing first word in `Deprecated` annotations, fix `Throws` and `See` tags --- .../src/main/kotlin/matchers/content/ContentMatchersDsl.kt | 14 +++++++------- .../src/main/kotlin/matchers/content/contentMatchers.kt | 7 +++---- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'core/content-matcher-test-utils/src') diff --git a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt index 67c0e692..264be933 100644 --- a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt +++ b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt @@ -3,7 +3,6 @@ package matchers.content import assertk.assertThat import assertk.assertions.contains import assertk.assertions.isEqualTo -import assertk.assertions.matches import org.jetbrains.dokka.model.withDescendants import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.test.tools.matchers.content.* @@ -53,12 +52,6 @@ fun ContentMatcherBuilder.hasExactText(expected: Strin } } -fun ContentMatcherBuilder.textMatches(pattern: Regex) { - assertions += { - assertThat(this::extractedText).matches(pattern) - } -} - inline fun ContentMatcherBuilder<*>.composite( block: ContentMatcherBuilder.() -> Unit ) { @@ -96,6 +89,13 @@ fun ContentMatcherBuilder<*>.table(block: ContentMatcherBuilder.() fun ContentMatcherBuilder<*>.platformHinted(block: ContentMatcherBuilder.() -> Unit) = composite { group(block) } +fun ContentMatcherBuilder<*>.list(block: ContentMatcherBuilder.() -> Unit) = composite(block) + +fun ContentMatcherBuilder<*>.caption(block: ContentMatcherBuilder.() -> Unit) = composite { + block() + check { assertThat(this::style).contains(ContentStyle.Caption) } +} + fun ContentMatcherBuilder<*>.br() = node() fun ContentMatcherBuilder<*>.somewhere(block: ContentMatcherBuilder<*>.() -> Unit) { diff --git a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt index f42e28f3..6a0e1c97 100644 --- a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt +++ b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt @@ -69,10 +69,9 @@ private class TextMatcherState( ) : MatchWalkerState() { override fun next(node: ContentNode): MatchWalkerState { node as? ContentText ?: throw MatcherError("Expected text: \"$text\" but got\n${node.debugRepresentation()}", anchor) - val trimmed = node.text.trim() return when { - text == trimmed -> rest.pop() - text.startsWith(trimmed) -> TextMatcherState(text.removePrefix(node.text).trim(), rest, anchor) + text == node.text -> rest.pop() + text.startsWith(node.text) -> TextMatcherState(text.removePrefix(node.text), rest, anchor) else -> throw MatcherError("Expected text: \"$text\", but got: \"${node.text}\"", anchor) } } @@ -111,7 +110,7 @@ private class SkippingMatcherState( private class FurtherSiblings(val list: List, val parent: CompositeMatcher<*>) { fun pop(): MatchWalkerState = when (val head = list.firstOrNull()) { - is TextMatcher -> TextMatcherState(head.text.trim(), drop(), head) + is TextMatcher -> TextMatcherState(head.text, drop(), head) is NodeMatcher<*> -> NodeMatcherState(head, drop()) is Anything -> SkippingMatcherState(drop().pop()) null -> EmptyMatcherState(parent) -- cgit