diff options
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 ""; } } |