diff options
author | vmishenev <vad-mishenev@yandex.ru> | 2021-08-20 02:14:36 +0300 |
---|---|---|
committer | vmishenev <vad-mishenev@yandex.ru> | 2021-08-30 19:53:24 +0300 |
commit | 721e0247e1a633882cb89e9c18d6be332054e87e (patch) | |
tree | a0292d13987740d21b37c6ab252c020a410a3bce /plugins/base/src/main/kotlin/translators | |
parent | 70448a0797202f91778c35ecd6adf4b36c95897d (diff) | |
download | dokka-721e0247e1a633882cb89e9c18d6be332054e87e.tar.gz dokka-721e0247e1a633882cb89e9c18d6be332054e87e.tar.bz2 dokka-721e0247e1a633882cb89e9c18d6be332054e87e.zip |
Handle `@link` tag
Diffstat (limited to 'plugins/base/src/main/kotlin/translators')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt index 8bc950b7..6de3e0e0 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -312,9 +312,8 @@ class JavadocParser( } private fun PsiElement.toDocumentationLinkString( - labelElement: List<PsiElement>? = null + label: String = "" ): String { - val label = labelElement?.toList().takeUnless { it.isNullOrEmpty() } ?: listOf(defaultLabel()) val dri = reference?.resolve()?.takeIf { it !is PsiParameter }?.let { val dri = DRI.from(it) @@ -322,7 +321,7 @@ class JavadocParser( dri.toString() } ?: UNRESOLVED_PSI_ELEMENT - return """<a data-dri="$dri">${label.joinToString(" ") { it.text }}</a>""" + return """<a data-dri="$dri">${label.ifBlank{ defaultLabel().text }}</a>""" } private fun convertInlineDocTag( @@ -332,7 +331,9 @@ class JavadocParser( ) = when (tag.name) { "link", "linkplain" -> tag.referenceElement() - ?.toDocumentationLinkString(tag.dataElements.filterIsInstance<PsiDocToken>()) + ?.toDocumentationLinkString(tag.dataElements.filterIsInstance<PsiDocToken>().joinToString("") { + it.stringifyElementAsText(keepFormatting = true).orEmpty() + }) "code" -> "<code data-inline>${dataElementsAsText(tag)}</code>" "literal" -> "<literal>${dataElementsAsText(tag)}</literal>" "index" -> "<index>${tag.children.filterIsInstance<PsiDocTagValue>().joinToString { it.text }}</index>" @@ -345,7 +346,7 @@ class JavadocParser( private fun dataElementsAsText(tag: PsiInlineDocTag) = tag.dataElements.joinToString("") { - it.stringifyElementAsText(keepFormatting = true).toString() + it.stringifyElementAsText(keepFormatting = true).orEmpty() }.htmlEscape() private fun createLink(element: Element, children: List<DocTag>): DocTag { |