aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt31
1 files changed, 10 insertions, 21 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
index a791f256..0e446e51 100644
--- a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
@@ -5,6 +5,7 @@ import com.intellij.psi.impl.source.javadoc.PsiDocParamRef
import com.intellij.psi.impl.source.tree.JavaDocElementType
import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.javadoc.*
+import com.intellij.psi.tree.java.IJavaDocElementType
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.doc.*
@@ -83,11 +84,10 @@ class JavadocParser(
"ul" -> Ul(children)
"ol" -> Ol(children)
"li" -> Li(children)
- //"a" -> createLink(element, children) // TODO: add proper inline link handling
+ "a" -> createLink(element, children)
else -> Text(body = element.ownText())
}
}
-/*
private fun createLink(element: Element, children: List<DocTag>): DocTag {
return when {
@@ -95,31 +95,20 @@ class JavadocParser(
A(children, params = mapOf("docref" to element.attr("docref")))
}
element.hasAttr("href") -> {
- val href = element.attr("href")
-
- val uri = try {
- A(children, params = mapOf("href" to href))
- } catch (_: Exception) {
- null
- }
-
- if (uri?.isAbsolute == false) {
- ContentLocalLink(href)
- } else {
- ContentExternalLink(href)
- }
- }
- element.hasAttr("name") -> {
- ContentBookmark(element.attr("name"))
+ A(children, params = mapOf("href" to element.attr("href")))
}
- else -> Text()
+ else -> Text(children = children)
}
- }*/
+ }
+
+ private fun PsiDocToken.isSharpToken() = tokenType.toString() == "DOC_TAG_VALUE_SHARP_TOKEN"
private fun PsiElement.toDocumentationLink(labelElement: PsiElement? = null) =
reference?.resolve()?.let {
val dri = DRI.from(it)
- val label = labelElement ?: children.firstOrNull { it is PsiDocToken && it.text.isNotBlank() } ?: this
+ val label = labelElement ?: children.firstOrNull {
+ it is PsiDocToken && it.text.isNotBlank() && !it.isSharpToken()
+ } ?: this
DocumentationLink(dri, convertJavadocElements(listOfNotNull(label)))
}