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

Add support for header tags in Javadoc #2345

Merged
merged 7 commits into from Feb 8, 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
Expand Up @@ -421,6 +421,9 @@ class JavadocParser(
parsed
}
}
"h1" -> ifChildrenPresent { H1(children) }
"h2" -> ifChildrenPresent { H2(children) }
"h3" -> ifChildrenPresent { H3(children) }
else -> listOf(Text(body = element.ownText()))
}
}
Expand Down
47 changes: 47 additions & 0 deletions plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
Expand Up @@ -349,4 +349,51 @@ class JavadocParserTest : BaseAbstractTest() {
}
}
}

@Test
fun `header tags are handled properly`() {
val source = """
|/src/main/kotlin/test/Test.java
|package example
|
| /**
| * An example of using the header tags
| * <h1>A header</h1>
| * <h2>A second level header</h2>
| * <h3>A third level header</h3>
| */
| public class Test {}
""".trimIndent()
testInline(
source,
configuration,
) {
documentablesCreationStage = { modules ->
val docs = modules.first().packages.first().classlikes.single().documentation.first().value
val root = docs.children.first().root

kotlin.test.assertEquals(
listOf(
P(children = listOf(Text("An example of using the header tags "))),
H1(
listOf(
Text("A header")
)
),
H2(
listOf(
Text("A second level header")
)
),
H3(
listOf(
Text("A third level header")
)
)
),
root.children
)
}
}
}
}