aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/signatures
diff options
context:
space:
mode:
authorvmishenev <vad-mishenev@yandex.ru>2021-08-25 17:14:31 +0300
committerGitHub <noreply@github.com>2021-08-25 16:14:31 +0200
commit4fa9524e52d8ff422bb355336e3810ab28ae135c (patch)
tree66d2bc381ffc7d5c598cee4ea9e0ba13f81b1d7b /plugins/base/src/test/kotlin/signatures
parent742f96bdf5c0b842e68dfaf43f4ab3446e87e3df (diff)
downloaddokka-4fa9524e52d8ff422bb355336e3810ab28ae135c.tar.gz
dokka-4fa9524e52d8ff422bb355336e3810ab28ae135c.tar.bz2
dokka-4fa9524e52d8ff422bb355336e3810ab28ae135c.zip
Manual highlighting webhelp (#2079)
* Add manual code highlighting * Fix test * Add kotlinAsJava highlighting * Add runtime highlighting via Prism * Add copy-button for code block * Add tests and refactor * Replace `<br>` for prism.js * Parse trivial default values Co-authored-by: Marcin Aman <marcin.aman@gmail.com>
Diffstat (limited to 'plugins/base/src/test/kotlin/signatures')
-rw-r--r--plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt33
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt74
-rw-r--r--plugins/base/src/test/kotlin/signatures/VarianceSignatureTest.kt12
3 files changed, 79 insertions, 40 deletions
diff --git a/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt
index 35d91175..e631117f 100644
--- a/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt
@@ -44,7 +44,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": (", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": (", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -62,7 +63,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": (", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": (", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -80,7 +82,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -98,7 +101,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": (param: ", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": (param: ", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -117,7 +121,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -135,7 +140,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -153,7 +159,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": suspend ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": suspend ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -171,7 +178,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "val ", A("nF"), ": suspend (param: ", A("Int"), ") -> ", A("String"), Span()
+ "val ", A("nF"), ": suspend (param: ", A("Int"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -202,7 +210,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
A("Boolean"),
") -> ",
A("String"),
- Span()
+ Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -227,7 +236,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-java-class/index.html").signature().last().match(
- "open val ", A("javaFunction"), ": (", A("Integer"), ") -> ", A("String"), Span()
+ "open val ", A("javaFunction"), ": (", A("Integer"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -252,7 +262,8 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-java-class/index.html").signature().last().match(
- "open val ", A("kotlinFunction"), ": (", A("Integer"), ") -> ", A("String"), Span()
+ "open val ", A("kotlinFunction"), ": (", A("Integer"), ") -> ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index a56c408b..d8b23d77 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -36,7 +36,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
- "fun ", A("simpleFun"), "(): ", A("String"), Span()
+ "fun ", A("simpleFun"), "(): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -54,7 +55,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
- "open fun ", A("simpleFun"), "(): ", A("String"), Span()
+ "open fun ", A("simpleFun"), "(): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -72,7 +74,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
- "open suspend fun ", A("simpleFun"), "(): ", A("String"), Span()
+ "open suspend fun ", A("simpleFun"), "(): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -92,7 +95,8 @@ class SignatureTest : BaseAbstractTest() {
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun ", A("simpleFun"), "(a: ", A("Int"),
", b: ", A("Boolean"), ", c: ", A("Any"),
- "): ", A("String"), Span()
+ "): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -111,7 +115,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun ", A("simpleFun"), "(a: (", A("Int"),
- ") -> ", A("String"), "): ", A("String"), Span()
+ ") -> ", A("String"), "): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -130,7 +135,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun <", A("T"), "> ", A("simpleFun"), "(): ",
- A("T"), Span()
+ A("T"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -149,7 +155,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun <", A("T"), " : ", A("String"), "> ", A("simpleFun"),
- "(): ", A("T"), Span()
+ "(): ", A("T"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -168,7 +175,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"inline suspend fun <", A("T"), " : ", A("String"), "> ", A("simpleFun"),
- "(a: ", A("Int"), ", b: ", A("String"), "): ", A("T"), Span()
+ "(a: ", A("Int"), ", b: ", A("String"), "): ", A("T"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -186,7 +194,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
- "fun ", A("simpleFun"), "(vararg params: ", A("Int"), ")", Span()
+ "fun ", A("simpleFun"), "(vararg params: ", A("Int"), ")", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -204,7 +213,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-simple-class/index.html").firstSignature().match(
- "class ", A("SimpleClass"), Span()
+ "class ", A("SimpleClass"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -223,7 +233,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-inheriting-class-from-generic-type/index.html").firstSignature().match(
"class ", A("InheritingClassFromGenericType"), " <", A("T"), " : ", A("Number"), ", ", A("R"), " : ", A("CharSequence"),
- "> : ", A("Comparable"), "<", A("T"), "> , ", A("Collection"), "<", A("R"), ">", Span()
+ "> : ", A("Comparable"), "<", A("T"), "> , ", A("Collection"), "<", A("R"), ">", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -241,7 +252,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-k-runnable/index.html").firstSignature().match(
- "fun interface ", A("KRunnable"), Span()
+ "fun interface ", A("KRunnable"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -273,7 +285,8 @@ class SignatureTest : BaseAbstractTest() {
Div("@", A("Marking"))
),
"fun ", A("simpleFun"),
- "(): ", A("String"), Span()
+ "(): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -307,7 +320,8 @@ class SignatureTest : BaseAbstractTest() {
Div("@set:", A("Marking"))
),
"var ", A("str"),
- ": ", A("String"), Span()
+ ": ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -347,7 +361,8 @@ class SignatureTest : BaseAbstractTest() {
Div("@", A("Marking2"), "(", Span("int = ", Span("1")), Wbr, ")")
),
"fun ", A("simpleFun"),
- "(): ", A("String"), Span()
+ "(): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -387,7 +402,8 @@ class SignatureTest : BaseAbstractTest() {
)
),
"fun ", A("simpleFun"),
- "(): ", A("String"), Span()
+ "(): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -436,7 +452,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("test/example/-foo/index.html").signature().toList()[1].match(
- "typealias ", A("Foo"), " = ", A("Bar"), Span()
+ "typealias ", A("Foo"), " = ", A("Bar"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -460,7 +477,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example.html").signature().first().match(
- "typealias ", A("PlainTypealias"), " = ", A("Int"), Span()
+ "typealias ", A("PlainTypealias"), " = ", A("Int"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -494,7 +512,8 @@ class SignatureTest : BaseAbstractTest() {
"@", A("SomeAnnotation")
)
),
- "typealias ", A("PlainTypealias"), " = ", A("Int"), Span()
+ "typealias ", A("PlainTypealias"), " = ", A("Int"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -519,7 +538,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example.html").signature().first().match(
"typealias ", A("PlainTypealias"), " = ", A("Comparable"),
- "<", A("Int"), ">", Span()
+ "<", A("Int"), ">", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -545,7 +565,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example.html").signature().first().match(
"typealias ", A("GenericTypealias"), "<", A("T"), "> = ", A("Comparable"),
- "<", A("T"), ">", Span()
+ "<", A("T"), ">", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -573,7 +594,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-a-b-c/some-fun.html").signature().first().match(
"fun ", A("someFun"), "(xd: ", A("XD"), "<", A("Int"),
- ", ", A("String"), ">):", A("Int"), Span()
+ ", ", A("String"), ">):", A("Int"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -618,7 +640,7 @@ class SignatureTest : BaseAbstractTest() {
arrayOf("fun ", A("GenericClass"), "(x: ", A("Int"), ")", Span()),
)
).forEach {
- it.first.match(*it.second)
+ it.first.match(*it.second, ignoreSpanWithTokenStyle = true)
}
}
}
@@ -637,7 +659,8 @@ class SignatureTest : BaseAbstractTest() {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun", A("simpleFun"), "(int: ", A("Int"), " = 1, string: ", A("String"),
- " = \"string\"): ", A("String"), Span()
+ " = \"string\"): ", A("String"), Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -655,7 +678,8 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
- "const val ", A("simpleVal"), ": ", A("Int"), " = 1", Span()
+ "const val ", A("simpleVal"), ": ", A("Int"), " = 1", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
diff --git a/plugins/base/src/test/kotlin/signatures/VarianceSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/VarianceSignatureTest.kt
index d988bafe..c5d49cec 100644
--- a/plugins/base/src/test/kotlin/signatures/VarianceSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/VarianceSignatureTest.kt
@@ -38,7 +38,8 @@ class VarianceSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-generic/index.html").firstSignature().match(
- "class ", A("Generic"), "<in ", A("T"), ">", Span()
+ "class ", A("Generic"), "<in ", A("T"), ">", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -56,7 +57,8 @@ class VarianceSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-generic/index.html").firstSignature().match(
- "class ", A("Generic"), "<out ", A("T"), ">", Span()
+ "class ", A("Generic"), "<out ", A("T"), ">", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -74,7 +76,8 @@ class VarianceSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-generic/index.html").firstSignature().match(
- "class ", A("Generic"), "<", A("T"), ">", Span()
+ "class ", A("Generic"), "<", A("T"), ">", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}
@@ -92,7 +95,8 @@ class VarianceSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-generic/index.html").firstSignature().match(
- "class ", A("Generic"), "<out ", A("T"), ":", A("List"), "<", A("CharSequence"), ">>", Span()
+ "class ", A("Generic"), "<out ", A("T"), ":", A("List"), "<", A("CharSequence"), ">>", Span(),
+ ignoreSpanWithTokenStyle = true
)
}
}