aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators/psi
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-06-30 13:44:08 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-01 09:43:03 +0200
commit4f5e54528427451de7741d8e5cdefaf550c2f36c (patch)
tree174967b9f0156e1a795f8f262d1af788f9ddb5d1 /plugins/base/src/main/kotlin/translators/psi
parent5090bfb7aec163b39202ef921555ed907b741b29 (diff)
downloaddokka-4f5e54528427451de7741d8e5cdefaf550c2f36c.tar.gz
dokka-4f5e54528427451de7741d8e5cdefaf550c2f36c.tar.bz2
dokka-4f5e54528427451de7741d8e5cdefaf550c2f36c.zip
JavadocParser: Remove unexpected whitespace from javadoc
Diffstat (limited to 'plugins/base/src/main/kotlin/translators/psi')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt15
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
index 7119ba68..89226821 100644
--- a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
@@ -122,13 +122,16 @@ class JavadocParser(
private fun getSeeTagElementContent(tag: PsiDocTag): List<DocTag> =
listOfNotNull(tag.referenceElement()?.toDocumentationLink())
- private fun PsiDocComment.getDescription(): Description? =
- convertJavadocElements(descriptionElements.dropWhile {
- it.text.trim().isEmpty()
- }).takeIf { it.isNotEmpty() }?.let { list ->
- Description(P(list))
+ private fun PsiDocComment.getDescription(): Description? {
+ val nonEmptyDescriptionElements = descriptionElements.filter { it.text.trim().isNotEmpty() }
+ val convertedDescriptionElements = convertJavadocElements(nonEmptyDescriptionElements)
+ if (convertedDescriptionElements.isNotEmpty()) {
+ return Description(P(convertedDescriptionElements))
}
+ return null
+ }
+
private fun convertJavadocElements(elements: Iterable<PsiElement>): List<DocTag> =
elements.mapNotNull {
when (it) {
@@ -136,7 +139,7 @@ class JavadocParser(
is PsiInlineDocTag -> listOfNotNull(convertInlineDocTag(it))
is PsiDocParamRef -> listOfNotNull(it.toDocumentationLink())
is PsiDocTagValue,
- is LeafPsiElement -> Jsoup.parse(it.text).body().childNodes().mapNotNull { convertHtmlNode(it) }
+ is LeafPsiElement -> Jsoup.parse(it.text.trim()).body().childNodes().mapNotNull(::convertHtmlNode)
else -> null
}
}.flatten()