aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvmishenev <vad-mishenev@yandex.ru>2021-08-20 02:14:36 +0300
committervmishenev <vad-mishenev@yandex.ru>2021-08-30 19:53:24 +0300
commit721e0247e1a633882cb89e9c18d6be332054e87e (patch)
treea0292d13987740d21b37c6ab252c020a410a3bce
parent70448a0797202f91778c35ecd6adf4b36c95897d (diff)
downloaddokka-721e0247e1a633882cb89e9c18d6be332054e87e.tar.gz
dokka-721e0247e1a633882cb89e9c18d6be332054e87e.tar.bz2
dokka-721e0247e1a633882cb89e9c18d6be332054e87e.zip
Handle `@link` tag
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt11
-rw-r--r--plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt7
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLinkingTest.kt2
3 files changed, 12 insertions, 8 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 {
diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
index f83ca55d..1a6dd6de 100644
--- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
+++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
@@ -256,14 +256,15 @@ class ContentForParamsTest : BaseAbstractTest() {
|/src/main/java/sample/DocGenProcessor.java
|package sample;
|/**
- | * Return the target fragment set by {@link #setTargetFragment}.
+ | * Return the target fragment set by {@link #setTargetFragment} or {@link
+ | * #setTargetFragment}.
| *
| * @deprecated Instead of using a target fragment to pass results, the fragment requesting a
| * result should use
| * {@link java.util.HashMap#containsKey(java.lang.Object) FragmentManager#setFragmentResult(String, Bundle)} to deliver results to
| * {@link java.util.HashMap#containsKey(java.lang.Object) FragmentResultListener} instances registered by other fragments via
| * {@link java.util.HashMap#containsKey(java.lang.Object) FragmentManager#setFragmentResultListener(String, LifecycleOwner,
- | * FragmentResultListener)}.
+ | * FragmentResultListener)}.
| */
| public class DocGenProcessor {
| public String setTargetFragment(){
@@ -286,6 +287,8 @@ class ContentForParamsTest : BaseAbstractTest() {
comment {
+"Return the target fragment set by "
link { +"setTargetFragment" }
+ +" or "
+ link { +"setTargetFragment" }
+"."
}
}
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLinkingTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLinkingTest.kt
index eb8abf9a..87c5246d 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLinkingTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLinkingTest.kt
@@ -45,7 +45,7 @@ class JavadocLinkingTest : BaseAbstractTest() {
| * Here comes some comment
| *
| * {@link example.SomeClass#someFun(int) someName(ads,
- | * dsa)}
+ | * dsa)}
| *
| * longer comment
| */