aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-30 19:01:09 +0100
committerGitHub <noreply@github.com>2020-10-30 19:01:09 +0100
commit1aba0ec4973d7915caa93f1e9b3146ad82111903 (patch)
treeb9424de4bc22f8453ecb32aaa8f7f020bcd49e9f /core
parentda498f50eabfad8969eb7795a535e97f7e25ca58 (diff)
downloaddokka-1aba0ec4973d7915caa93f1e9b3146ad82111903.tar.gz
dokka-1aba0ec4973d7915caa93f1e9b3146ad82111903.tar.bz2
dokka-1aba0ec4973d7915caa93f1e9b3146ad82111903.zip
Fix parsing first word in deprecated (#1595)
Fix parsing first word in `Deprecated` annotations, fix `Throws` and `See` tags
Diffstat (limited to 'core')
-rw-r--r--core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt14
-rw-r--r--core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt7
-rw-r--r--core/src/main/kotlin/model/doc/DocTag.kt5
-rw-r--r--core/src/main/kotlin/model/doc/TagWrapper.kt2
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt3
5 files changed, 18 insertions, 13 deletions
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 <T : ContentComposite> ContentMatcherBuilder<T>.hasExactText(expected: Strin
}
}
-fun <T : ContentComposite> ContentMatcherBuilder<T>.textMatches(pattern: Regex) {
- assertions += {
- assertThat(this::extractedText).matches(pattern)
- }
-}
-
inline fun <reified S : ContentComposite> ContentMatcherBuilder<*>.composite(
block: ContentMatcherBuilder<S>.() -> Unit
) {
@@ -96,6 +89,13 @@ fun ContentMatcherBuilder<*>.table(block: ContentMatcherBuilder<ContentTable>.()
fun ContentMatcherBuilder<*>.platformHinted(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) =
composite<PlatformHintedContent> { group(block) }
+fun ContentMatcherBuilder<*>.list(block: ContentMatcherBuilder<ContentList>.() -> Unit) = composite(block)
+
+fun ContentMatcherBuilder<*>.caption(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) = composite<ContentGroup> {
+ block()
+ check { assertThat(this::style).contains(ContentStyle.Caption) }
+}
+
fun ContentMatcherBuilder<*>.br() = node<ContentBreakLine>()
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<MatcherElement>, 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)
diff --git a/core/src/main/kotlin/model/doc/DocTag.kt b/core/src/main/kotlin/model/doc/DocTag.kt
index 04b5c913..7698ebb3 100644
--- a/core/src/main/kotlin/model/doc/DocTag.kt
+++ b/core/src/main/kotlin/model/doc/DocTag.kt
@@ -354,3 +354,8 @@ data class Var(
override val children: List<DocTag> = emptyList(),
override val params: Map<String, String> = emptyMap()
) : DocTag()
+
+data class Caption(
+ override val children: List<DocTag> = emptyList(),
+ override val params: Map<String, String> = emptyMap()
+) : DocTag() \ No newline at end of file
diff --git a/core/src/main/kotlin/model/doc/TagWrapper.kt b/core/src/main/kotlin/model/doc/TagWrapper.kt
index cfe99b1e..cea132a8 100644
--- a/core/src/main/kotlin/model/doc/TagWrapper.kt
+++ b/core/src/main/kotlin/model/doc/TagWrapper.kt
@@ -22,7 +22,7 @@ data class Param(override val root: DocTag, override val name: String) : NamedTa
data class Return(override val root: DocTag) : TagWrapper()
data class Receiver(override val root: DocTag) : TagWrapper()
data class Constructor(override val root: DocTag) : TagWrapper()
-data class Throws(override val root: DocTag, override val name: String) : NamedTagWrapper()
+data class Throws(override val root: DocTag, override val name: String, val exceptionAddress: DRI?) : NamedTagWrapper()
data class Sample(override val root: DocTag, override val name: String) : NamedTagWrapper()
data class Deprecated(override val root: DocTag) : TagWrapper()
data class Property(override val root: DocTag, override val name: String) : NamedTagWrapper()
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt
index 77e6ebb2..303fa803 100644
--- a/core/src/main/kotlin/pages/ContentNodes.kt
+++ b/core/src/main/kotlin/pages/ContentNodes.kt
@@ -182,6 +182,7 @@ interface ContentComposite : ContentNode {
/** Tables */
data class ContentTable(
val header: List<ContentGroup>,
+ val caption: ContentGroup? = null,
override val children: List<ContentGroup>,
override val dci: DCI,
override val sourceSets: Set<DisplaySourceSet>,
@@ -343,7 +344,7 @@ enum class TextStyle : Style {
}
enum class ContentStyle : Style {
- RowTitle, TabbedContent, WithExtraAttributes, RunnableSample, InDocumentationAnchor
+ RowTitle, TabbedContent, WithExtraAttributes, RunnableSample, InDocumentationAnchor, Caption
}
object CommentTable : Style