diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-27 17:42:52 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-27 17:42:52 +0100 |
commit | 7b91d7dd32e953674d66dbfb7ef6306258b1cfb7 (patch) | |
tree | ee5835ce521f9d103e1d50cc8bdc75747e0d001d | |
parent | 63faa143fbc841d0e21a9903c51b3d9ab0216b92 (diff) | |
download | dokka-7b91d7dd32e953674d66dbfb7ef6306258b1cfb7.tar.gz dokka-7b91d7dd32e953674d66dbfb7ef6306258b1cfb7.tar.bz2 dokka-7b91d7dd32e953674d66dbfb7ef6306258b1cfb7.zip |
don't lose space after first word in the content of javadoc tags
-rw-r--r-- | src/Java/JavaDocumentationBuilder.kt | 18 | ||||
-rw-r--r-- | test/data/format/javaDeprecated.html | 2 | ||||
-rw-r--r-- | test/data/format/javaSpaceInAuthor.java | 7 | ||||
-rw-r--r-- | test/data/format/javaSpaceInAuthor.md | 13 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 6 |
5 files changed, 38 insertions, 8 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index 1a28de47..4b1b8116 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -1,10 +1,7 @@ package org.jetbrains.dokka import com.intellij.psi.* -import com.intellij.psi.javadoc.PsiDocComment -import com.intellij.psi.javadoc.PsiDocTag -import com.intellij.psi.javadoc.PsiDocTagValue -import com.intellij.psi.javadoc.PsiInlineDocTag +import com.intellij.psi.javadoc.* import org.jetbrains.dokka.DocumentationNode.Kind import org.jsoup.Jsoup import org.jsoup.nodes.Element @@ -32,20 +29,27 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, "see" -> result.convertSeeTag(tag) "deprecated" -> { deprecatedContent = Content() - deprecatedContent!!.convertJavadocElements(tag.getDataElements().toArrayList()) + deprecatedContent!!.convertJavadocElements(tag.contentElements()) } else -> { val subjectName = tag.getSubjectName() val section = result.addSection(javadocSectionDisplayName(tag.getName()), subjectName) - section.convertJavadocElements( - tag.getDataElements().filter { it !is PsiDocTagValue || tag.getSubjectName() == null }) + section.convertJavadocElements(tag.contentElements()) } } } return JavadocParseResult(result, deprecatedContent) } + private fun PsiDocTag.contentElements(): Iterable<PsiElement> { + val tagValueElements = getChildren() + .dropWhile { it.getNode().getElementType() == JavaDocTokenType.DOC_TAG_NAME } + .dropWhile { it is PsiWhiteSpace } + .filterNot { it.getNode().getElementType() == JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS } + return if (getSubjectName() != null) tagValueElements.dropWhile { it is PsiDocTagValue } else tagValueElements + } + private fun ContentBlock.convertJavadocElements(elements: Iterable<PsiElement>) { val htmlBuilder = StringBuilder() elements.forEach { diff --git a/test/data/format/javaDeprecated.html b/test/data/format/javaDeprecated.html index f9376bf5..8410e7ca 100644 --- a/test/data/format/javaDeprecated.html +++ b/test/data/format/javaDeprecated.html @@ -7,7 +7,7 @@ <br/> <h1>foo</h1> <code><span class="keyword">public</span> <span class="keyword">open</span> <span class="keyword">fun </span><s><span class="identifier">foo</span></s><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code><br/> -<strong>Deprecated:</strong> use<code><a href="test/test/-foo/bar">#bar</a></code> instead <p></p> +<strong>Deprecated:</strong> use <code><a href="test/test/-foo/bar">#bar</a></code> instead <p></p> <br/> <br/> </BODY> diff --git a/test/data/format/javaSpaceInAuthor.java b/test/data/format/javaSpaceInAuthor.java new file mode 100644 index 00000000..b96f5884 --- /dev/null +++ b/test/data/format/javaSpaceInAuthor.java @@ -0,0 +1,7 @@ +package test; + +/** + * @author Dmitry Jemerov + */ +class C { +}
\ No newline at end of file diff --git a/test/data/format/javaSpaceInAuthor.md b/test/data/format/javaSpaceInAuthor.md new file mode 100644 index 00000000..425d4c9a --- /dev/null +++ b/test/data/format/javaSpaceInAuthor.md @@ -0,0 +1,13 @@ +[test](test/index) / [test](test/test/index) / [C](test/test/-c) + + +# C + +`open class C` + + + +**Author** +Dmitry Jemerov + + diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 49d2ec1b..0452645a 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -136,4 +136,10 @@ public class MarkdownFormatTest { markdownService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun javaSpaceInAuthor() { + verifyOutput("test/data/format/javaSpaceInAuthor.java", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } } |