aboutsummaryrefslogtreecommitdiff
path: root/src/Java
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-20 18:56:43 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-20 18:56:43 +0100
commitff0e6be0369f2778d33fd7aa4821548745172b80 (patch)
tree4bb185e80561ecad52360ee3713be2dbf6a26fe5 /src/Java
parentf26fccd1ed4cdb399c41f87541099d8cc9f85417 (diff)
downloaddokka-ff0e6be0369f2778d33fd7aa4821548745172b80.tar.gz
dokka-ff0e6be0369f2778d33fd7aa4821548745172b80.tar.bz2
dokka-ff0e6be0369f2778d33fd7aa4821548745172b80.zip
process @link and @linkplain tags in javadoc
Diffstat (limited to 'src/Java')
-rw-r--r--src/Java/JavaDocumentationBuilder.kt27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index e1b91470..ddc526ac 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -4,6 +4,7 @@ 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 org.jetbrains.dokka.DocumentationNode.Kind
public class JavaDocumentationBuilder(private val options: DocumentationOptions,
@@ -18,9 +19,15 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
fun parseDocumentation(docComment: PsiDocComment?): Content {
if (docComment == null) return Content.Empty
val result = Content()
+ val para = ContentParagraph()
+ result.append(para)
docComment.getDescriptionElements().dropWhile { it.getText().trim().isEmpty() }.forEach {
- val text = if (result.isEmpty()) it.getText().trimLeading() else it.getText()
- result.append(ContentText(text))
+ if (it is PsiInlineDocTag) {
+ para.append(convertInlineDocTag(it))
+ } else {
+ val text = if (para.isEmpty()) it.getText().trimLeading() else it.getText()
+ para.append(ContentText(text))
+ }
}
docComment.getTags().forEach { tag ->
val subjectName = tag.getSubjectName()
@@ -34,6 +41,22 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
return result
}
+ 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? {
+ val target = valueElement?.getReference()?.resolve()
+ if (target != null) {
+ val signature = getSignature(target)
+ if (signature != null) {
+ return ContentNodeLazyLink(valueElement!!.getText(), {() -> signatureToNode[signature]})
+ }
+ }
+ return null
+ }
+
fun PsiDocTag.getSubjectName(): String? {
if (getName() == "param" || getName() == "throws" || getName() == "exception") {
return getValueElement()?.getText()