aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Java/JavadocParser.kt
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-04-27 18:05:35 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-07-14 23:57:11 +0300
commit57a6bb55ddafbde4eab7c1c4344fff3ad3f0fe1f (patch)
tree3c180c9e89676df853f80fdfc87e7199a28d2d5a /core/src/main/kotlin/Java/JavadocParser.kt
parenteba83fb593ebae4c3d1498969feb0dc5a085689c (diff)
downloaddokka-57a6bb55ddafbde4eab7c1c4344fff3ad3f0fe1f.tar.gz
dokka-57a6bb55ddafbde4eab7c1c4344fff3ad3f0fe1f.tar.bz2
dokka-57a6bb55ddafbde4eab7c1c4344fff3ad3f0fe1f.zip
[backport] KT-24042: Fix structure of content paragraphs in Javadoc parser
Original: edc0581
Diffstat (limited to 'core/src/main/kotlin/Java/JavadocParser.kt')
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt29
1 files changed, 21 insertions, 8 deletions
diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt
index 365ae298..08ae5354 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -30,9 +30,18 @@ class JavadocParser(
if (docComment == null) return JavadocParseResult.Empty
val result = MutableContent()
var deprecatedContent: Content? = null
- val para = ContentParagraph()
- result.append(para)
- para.convertJavadocElements(docComment.descriptionElements.dropWhile { it.text.trim().isEmpty() })
+ val firstParagraph = ContentParagraph()
+ firstParagraph.convertJavadocElements(docComment.descriptionElements.dropWhile { it.text.trim().isEmpty() })
+ val paragraphs = firstParagraph.children.dropWhile { it !is ContentParagraph }
+ firstParagraph.children.removeAll(paragraphs)
+ if (!firstParagraph.isEmpty()) {
+ result.append(firstParagraph)
+ }
+ paragraphs.forEach {
+ result.append(it)
+ }
+ val attrs = mutableListOf<DocumentationNode>()
+ var since: DocumentationNode? = null
docComment.tags.forEach { tag ->
when (tag.name) {
"see" -> result.convertSeeTag(tag)
@@ -70,20 +79,24 @@ class JavadocParser(
}
val doc = Jsoup.parse(htmlBuilder.toString().trim())
doc.body().childNodes().forEach {
- convertHtmlNode(it)
+ convertHtmlNode(it)?.let { append(it) }
}
}
- private fun ContentBlock.convertHtmlNode(node: Node) {
+ private fun convertHtmlNode(node: Node): ContentNode? {
if (node is TextNode) {
- append(ContentText(node.text()))
+ return ContentText(node.text())
} else if (node is Element) {
val childBlock = createBlock(node)
node.childNodes().forEach {
- childBlock.convertHtmlNode(it)
+ val child = convertHtmlNode(it)
+ if (child != null) {
+ childBlock.append(child)
+ }
}
- append(childBlock)
+ return (childBlock)
}
+ return null
}
private fun createBlock(element: Element): ContentBlock = when (element.tagName()) {