aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-03-24 05:04:10 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-03-25 12:40:43 +0100
commit646d2fbd2a0d1e898a14ac942c43511bfd0a1c95 (patch)
tree3b1a4dad8129f2772c17eb4a1fb1436fd0f33abf /plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
parentc09bde34ff729ef9b1f3bea602fb53cd4e6dca42 (diff)
downloaddokka-646d2fbd2a0d1e898a14ac942c43511bfd0a1c95.tar.gz
dokka-646d2fbd2a0d1e898a14ac942c43511bfd0a1c95.tar.bz2
dokka-646d2fbd2a0d1e898a14ac942c43511bfd0a1c95.zip
Fixing incorrect psi parsing
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)))
}