aboutsummaryrefslogtreecommitdiff
path: root/dokka-subprojects/plugin-base/src/test
diff options
context:
space:
mode:
authorAndrey Tyrin <andrei.tyrin@jetbrains.com>2023-11-14 16:35:45 +0100
committerGitHub <noreply@github.com>2023-11-14 16:35:45 +0100
commit94a4edd5ccf43fbdb6ed833761afe659b82d4bf9 (patch)
tree80d7844068ccdcd427d82886260f20f17ea846aa /dokka-subprojects/plugin-base/src/test
parent1fb8d316f519faa2694447fd11a92a8b2c78dd61 (diff)
downloaddokka-94a4edd5ccf43fbdb6ed833761afe659b82d4bf9.tar.gz
dokka-94a4edd5ccf43fbdb6ed833761afe659b82d4bf9.tar.bz2
dokka-94a4edd5ccf43fbdb6ed833761afe659b82d4bf9.zip
Remove empty spans rendering for missed modifiers (#3343)
* Remove property modifiers if there are none * Remove variance modifier rendering if it is absent
Diffstat (limited to 'dokka-subprojects/plugin-base/src/test')
-rw-r--r--dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt66
1 files changed, 64 insertions, 2 deletions
diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt
index 80a043fe..3099400e 100644
--- a/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt
@@ -198,6 +198,27 @@ class SignatureTest : BaseAbstractTest() {
}
@Test
+ fun `fun with use site variance modifier in`() {
+ val source = source("fun simpleFun(params: Array<in String>): Unit")
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ source,
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
+ "fun ", A("simpleFun"), "(", Parameters(
+ Parameter("params: ", A("Array"), "<in ", A("String"), ">"),
+ ), ")",
+ ignoreSpanWithTokenStyle = true
+ )
+ }
+ }
+ }
+
+ @Test
fun `fun with definitely non-nullable types`() {
val source = source("fun <T> elvisLike(x: T, y: T & Any): T & Any = x ?: y")
val writerPlugin = TestOutputWriterPlugin()
@@ -313,6 +334,48 @@ class SignatureTest : BaseAbstractTest() {
}
@Test
+ fun `class with declaration site variance modifier`() {
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/common/Test.kt
+ |package example
+ |
+ |class PrimaryConstructorClass<out T> { }
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ writerPlugin.writer.renderedContent("root/example/-primary-constructor-class/index.html").firstSignature().match(
+ Span("class "), A("PrimaryConstructorClass"), Span("<"), Span("out "), A("T"), Span(">"),
+ )
+ }
+ }
+ }
+
+ @Test
+ fun `constructor property on class page`() {
+ val source = source("data class DataClass(val arg: String)")
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ source,
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ assertEquals(
+ writerPlugin.writer.renderedContent("root/example/-data-class/index.html").lastSignature().html(),
+ "<span class=\"token keyword\">val </span><a href=\"arg.html\">arg</a><span class=\"token operator\">: </span><a href=\"https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html\">String</a>"
+
+ )
+ }
+ }
+ }
+
+ @Test
fun `functional interface`() {
val source = source("fun interface KRunnable")
val writerPlugin = TestOutputWriterPlugin()
@@ -896,8 +959,7 @@ class SignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-primary-constructor-class/index.html").firstSignature().match(
- // In `<T>` expression, an empty `<span class="token keyword"></span>` is present for some reason
- Span("class "), A("PrimaryConstructorClass"), Span("<"), Span(), A("T"), Span(">"), Span("("), Parameters(
+ Span("class "), A("PrimaryConstructorClass"), Span("<"), A("T"), Span(">"), Span("("), Parameters(
Parameter(Span("val "), "x", Span(": "), A("Int"), Span(",")),
Parameter(Span("var "), "s", Span(": "), A("String"))
), Span(")"),