diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-06-30 13:44:08 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-01 09:43:03 +0200 |
commit | 4f5e54528427451de7741d8e5cdefaf550c2f36c (patch) | |
tree | 174967b9f0156e1a795f8f262d1af788f9ddb5d1 /plugins | |
parent | 5090bfb7aec163b39202ef921555ed907b741b29 (diff) | |
download | dokka-4f5e54528427451de7741d8e5cdefaf550c2f36c.tar.gz dokka-4f5e54528427451de7741d8e5cdefaf550c2f36c.tar.bz2 dokka-4f5e54528427451de7741d8e5cdefaf550c2f36c.zip |
JavadocParser: Remove unexpected whitespace from javadoc
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt | 15 | ||||
-rw-r--r-- | plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt | 6 |
2 files changed, 12 insertions, 9 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() diff --git a/plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt index 4c6e17f0..9e18c921 100644 --- a/plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt @@ -6,9 +6,9 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import testApi.utils.assertIsInstance -@Disabled("To be fixed") internal class JavadocClasslikeTemplateMapTest : AbstractJavadocTemplateMapTest() { + @Disabled("To be fixed") @Test fun `empty class`() { dualTestTemplateMapInline( @@ -65,11 +65,11 @@ internal class JavadocClasslikeTemplateMapTest : AbstractJavadocTemplateMapTest( /** * Documentation for TestClass */ - public class TestClass { + public final class TestClass { /** * Documentation for testFunction */ - public String testFunction() { + public final String testFunction() { return ""; } } |