dokka
dokka copied to clipboard
KDoc parser: Missing space between consecutive composite leaf nodes in markdown parser
Describe the bug
/** Rotates paths by `amount` **radians** around (`x`, `y`). */
rendered
Rotates paths by `amount`**radians** around (`x`, `y`).
Expected behaviour
Rotates paths by `amount` **radians** around (`x`, `y`).
To Reproduce
Actual bug is in KDoc parser, to reproduce - add test below in ParserTest.kt
Actually passes with Text(" ")
commented-out, while should with uncommented.
@Test
fun `Code and bold`() {
val kdoc = "Rotates paths by `amount` **radians** around (`x`, `y`)."
val expectedDocumentationNode = DocumentationNode(
listOf(
Description(
CustomDocTag(
listOf(
P(
listOf(
Text("Rotates paths by "),
CodeInline(listOf(Text("amount"))),
//Text(" "),
B(listOf(Text("radians"))),
Text(" around ("),
CodeInline(listOf(Text("x"))),
Text(", "),
CodeInline(listOf(Text("y"))),
Text(")."),
)
)
), name = MarkdownElementTypes.MARKDOWN_FILE.name
)
)
)
)
executeTest(kdoc, expectedDocumentationNode)
}
@Test
fun `Code with backticks`() {
val kdoc = "` `` ` ` ``` `"
val expectedDocumentationNode = DocumentationNode(
listOf(
Description(
CustomDocTag(
listOf(
P(
listOf(
CodeInline(listOf(Text("`` "))),
//Text(" "),
CodeInline(listOf(Text("``` "))),
)
)
), name = MarkdownElementTypes.MARKDOWN_FILE.name
)
)
)
)
executeTest(kdoc, expectedDocumentationNode)
}
Traced - space is removed in https://github.com/Kotlin/dokka/blob/c2182b766a65619c859c0fc871a8a6334d66f199/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt#L446 On entry it is here, on exit - dropped.
Why?
There's also some more investigation done by me in https://github.com/Kotlin/dokka/issues/2446#issuecomment-1101476609
The fix will be in Dokka 1.7.20.