From 649217db5c05dbb466371870a2761f9c32b086f0 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 20 Feb 2015 19:15:11 +0100 Subject: process @see tags in javadoc --- src/Java/JavaDocumentationBuilder.kt | 28 ++++++++++++++++++++++------ test/data/format/javaSeeTag.html | 27 +++++++++++++++++++++++++++ test/data/format/javaSeeTag.java | 8 ++++++++ test/src/format/HtmlFormatTest.kt | 6 ++++++ 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 test/data/format/javaSeeTag.html create mode 100644 test/data/format/javaSeeTag.java diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index ddc526ac..5d54e214 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -30,23 +30,39 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, } } docComment.getTags().forEach { tag -> - val subjectName = tag.getSubjectName() - val section = result.addSection(javadocSectionDisplayName(tag.getName()), subjectName) - tag.getDataElements().forEach { - if (it !is PsiDocTagValue || tag.getSubjectName() == null) { - section.append(ContentText(it.getText())) + if (tag.getName() == "see") { + result.convertSeeTag(tag) + } else { + val subjectName = tag.getSubjectName() + val section = result.addSection(javadocSectionDisplayName(tag.getName()), subjectName) + tag.getDataElements().forEach { + if (it !is PsiDocTagValue || tag.getSubjectName() == null) { + section.append(ContentText(it.getText())) + } } } } return result } + private fun Content.convertSeeTag(tag: PsiDocTag) { + val seeSection = findSectionByTag("See Also") ?: addSection("See Also", null) + val linkNode = resolveLink(tag.getValueElement()) + val text = ContentText(tag.getValueElement()!!.getText()) + if (linkNode != null) { + linkNode.append(text) + seeSection.append(linkNode) + } else { + seeSection.append(text) + } + } + private fun convertInlineDocTag(tag: PsiInlineDocTag) = when (tag.getName()) { "link", "linkplain" -> resolveLink(tag.getValueElement()) ?: ContentText(tag.getText()) else -> ContentText(tag.getText()) } - private fun resolveLink(valueElement: PsiDocTagValue?): ContentNode? { + private fun resolveLink(valueElement: PsiDocTagValue?): ContentBlock? { val target = valueElement?.getReference()?.resolve() if (target != null) { val signature = getSignature(target) diff --git a/test/data/format/javaSeeTag.html b/test/data/format/javaSeeTag.html new file mode 100644 index 00000000..392b1d2e --- /dev/null +++ b/test/data/format/javaSeeTag.html @@ -0,0 +1,27 @@ + + +test / test.Foo + + +test / test / Foo
+
+

Foo

+open class Foo : Any
+

+See Also
+#bar
+
+
+

Functions

+ + + + + + + +
+bar +public open fun bar(): Unit
+ + diff --git a/test/data/format/javaSeeTag.java b/test/data/format/javaSeeTag.java new file mode 100644 index 00000000..e0b95f11 --- /dev/null +++ b/test/data/format/javaSeeTag.java @@ -0,0 +1,8 @@ +package test; + +/** + * @see #bar + */ +class Foo { + public void bar() {} +} \ No newline at end of file diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index 030b72f8..feeab186 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -105,4 +105,10 @@ public class HtmlFormatTest { htmlService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun javaSeeTag() { + verifyOutput("test/data/format/javaSeeTag.java", ".html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members.single().members) + } + } } -- cgit