aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-04-27 16:13:13 +0300
committerGitHub <noreply@github.com>2022-04-27 16:13:13 +0300
commit2aabdea6113da6cb50edf18afb146b7120071e68 (patch)
treee4cf90a1d9d41dec29d5950cee4df3f960c0d3cc /plugins/base
parenta43f710c7802f418f8ca3b41ef8ac726c75987aa (diff)
downloaddokka-2aabdea6113da6cb50edf18afb146b7120071e68.tar.gz
dokka-2aabdea6113da6cb50edf18afb146b7120071e68.tar.bz2
dokka-2aabdea6113da6cb50edf18afb146b7120071e68.zip
Fix empty parentheses for no-arg enum entry (#2470)
* Fix empty parentheses for no-arg enum entry Fixes #2355 * Move parentheses punctuation inside `list` call * Revert formatting * Correct expected ordering of enum entries in tests
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt4
-rw-r--r--plugins/base/src/test/kotlin/enums/EnumsTest.kt1
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt37
3 files changed, 39 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 3c9daa29..612f9ace 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -80,13 +80,13 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
link(e.name, e.dri, styles = emptySet())
e.extra[ConstructorValues]?.let { constructorValues ->
constructorValues.values[it]?.let { values ->
- punctuation("(")
list(
elements = values,
+ prefix = "(",
+ suffix = ")",
separator = ", ",
separatorStyles = mainStyles + TokenStyle.Punctuation,
) { highlightValue(it) }
- punctuation(")")
}
}
}
diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
index 778125e2..ee4de696 100644
--- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt
+++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
@@ -400,7 +400,6 @@ class EnumsTest : BaseAbstractTest() {
group {
group {
link { +"E1" }
- +"()"
}
}
group {
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index 6f4de32b..c290846e 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -857,4 +857,41 @@ class SignatureTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `should have no empty parentheses for no-arg enum entry`() {
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/common/EnumClass.kt
+ |package example
+ |
+ |enum class EnumClass(param: String = "Default") {
+ | EMPTY,
+ | WITH_ARG("arg")
+ |}
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val enumEntrySignatures = writerPlugin.writer.renderedContent("root/example/-enum-class/index.html")
+ .select("div.table[data-togglable=Entries]")
+ .single()
+ .signature()
+ .select("div.block")
+
+ enumEntrySignatures[0].match(
+ A("EMPTY"),
+ ignoreSpanWithTokenStyle = true
+ )
+
+ enumEntrySignatures[1].match(
+ A("WITH_ARG"), "(\"arg\")",
+ ignoreSpanWithTokenStyle = true
+ )
+ }
+ }
+ }
}