Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty parentheses for no-arg enum entry #2470

Merged
merged 4 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(")")
}
}
}
Expand Down
1 change: 0 additions & 1 deletion plugins/base/src/test/kotlin/enums/EnumsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ class EnumsTest : BaseAbstractTest() {
group {
group {
link { +"E1" }
+"()"
}
}
group {
Expand Down
37 changes: 37 additions & 0 deletions plugins/base/src/test/kotlin/signatures/SignatureTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
}
}