aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Java/JavaDocumentationBuilder.kt28
-rw-r--r--test/data/format/javaSeeTag.html27
-rw-r--r--test/data/format/javaSeeTag.java8
-rw-r--r--test/src/format/HtmlFormatTest.kt6
4 files changed, 63 insertions, 6 deletions
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 @@
+<HTML>
+<HEAD>
+<title>test / test.Foo</title>
+</HEAD>
+<BODY>
+<a href="test/index">test</a>&nbsp;/&nbsp;<a href="test/test/index">test</a>&nbsp;/&nbsp;<a href="test/test/-foo/index">Foo</a><br/>
+<br/>
+<h1>Foo</h1>
+<code><span class="keyword">open</span> <span class="keyword">class </span><span class="identifier">Foo</span><span class="symbol"> : </span><span class="identifier">Any</span></code><br/>
+<p></p>
+<strong>See Also</strong><br/>
+<a href="test/test/-foo/bar">#bar</a><br/>
+<br/>
+<br/>
+<h3>Functions</h3>
+<table>
+<tbody>
+<tr>
+<td>
+<a href="test/test/-foo/bar">bar</a></td>
+<td>
+<code><span class="keyword">public</span> <span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
+</tr>
+</tbody>
+</table>
+</BODY>
+</HTML>
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)
+ }
+ }
}