aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/parsers/MarkdownParser.kt23
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt18
2 files changed, 28 insertions, 13 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
index d3006f33..ebcb1b43 100644
--- a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
+++ b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
@@ -12,6 +12,7 @@ import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
import org.intellij.markdown.flavours.gfm.GFMTokenTypes
import org.jetbrains.dokka.base.parsers.factories.DocTagsFromIElementFactory
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.model.doc.Suppress
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
@@ -51,7 +52,7 @@ open class MarkdownParser(
val dri = externalDri(referencedName)
See(
parseStringToDocNode(content.substringAfter(' ')),
- dri?.fqName() ?: referencedName,
+ dri?.fqDeclarationName() ?: referencedName,
dri
)
}
@@ -59,7 +60,7 @@ open class MarkdownParser(
val dri = externalDri(content.substringBefore(' '))
Throws(
parseStringToDocNode(content.substringAfter(' ')),
- dri?.fqName() ?: content.substringBefore(' '),
+ dri?.fqDeclarationName() ?: content.substringBefore(' '),
dri
)
}
@@ -523,7 +524,7 @@ open class MarkdownParser(
val dri = pointedLink(it)
Throws(
parseStringToDocNode(it.getContent()),
- dri?.fqName() ?: it.getSubjectName().orEmpty(),
+ dri?.fqDeclarationName() ?: it.getSubjectName().orEmpty(),
dri,
)
}
@@ -531,7 +532,7 @@ open class MarkdownParser(
val dri = pointedLink(it)
Throws(
parseStringToDocNode(it.getContent()),
- dri?.fqName() ?: it.getSubjectName().orEmpty(),
+ dri?.fqDeclarationName() ?: it.getSubjectName().orEmpty(),
dri
)
}
@@ -545,7 +546,7 @@ open class MarkdownParser(
val dri = pointedLink(it)
See(
parseStringToDocNode(it.getContent()),
- dri?.fqName() ?: it.getSubjectName().orEmpty(),
+ dri?.fqDeclarationName() ?: it.getSubjectName().orEmpty(),
dri,
)
}
@@ -567,8 +568,20 @@ open class MarkdownParser(
}
//Horrible hack but since link resolution is passed as a function i am not able to resolve them otherwise
+ @kotlin.Suppress("DeprecatedCallableAddReplaceWith")
+ @Deprecated("This function makes wrong assumptions and is missing a lot of corner cases related to generics, " +
+ "parameters and static members. This is not supposed to be public API and will not be supported in the future")
fun DRI.fqName(): String? = "$packageName.$classNames".takeIf { packageName != null && classNames != null }
+ private fun DRI.fqDeclarationName(): String? {
+ if (this.target !is PointingToDeclaration) {
+ return null
+ }
+ return listOfNotNull(this.packageName, this.classNames, this.callable?.name)
+ .joinToString(separator = ".")
+ .takeIf { it.isNotBlank() }
+ }
+
private fun findParent(kDoc: PsiElement): PsiElement =
if (kDoc.canHaveParent()) findParent(kDoc.parent) else kDoc
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index de31e448..44e2728a 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -11,6 +11,7 @@ import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentCon
import org.jetbrains.dokka.base.transformers.pages.tags.CustomTagContentProvider
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder.DocumentableContentBuilder
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.model.properties.PropertyContainer
@@ -592,26 +593,26 @@ open class DefaultPageCreator(
availablePlatforms.forEach { platform ->
val possibleFallbacks = sourceSets.getPossibleFallbackSourcesets(platform)
seeAlsoTags.forEach { (_, see) ->
- (see[platform] ?: see.fallback(possibleFallbacks))?.let {
+ (see[platform] ?: see.fallback(possibleFallbacks))?.let { seeTag ->
row(
sourceSets = setOf(platform),
kind = ContentKind.Comment,
styles = this@group.mainStyles,
) {
- it.address?.let { dri ->
+ seeTag.address?.let { dri ->
link(
- dri.classNames ?: it.name,
- dri,
+ text = seeTag.name.removePrefix("${dri.packageName}."),
+ address = dri,
kind = ContentKind.Comment,
styles = mainStyles + ContentStyle.RowTitle
)
} ?: text(
- it.name,
+ text = seeTag.name,
kind = ContentKind.Comment,
styles = mainStyles + ContentStyle.RowTitle
)
- if (it.isNotEmpty()) {
- comment(it.root)
+ if (seeTag.isNotEmpty()) {
+ comment(seeTag.root)
}
}
}
@@ -641,7 +642,8 @@ open class DefaultPageCreator(
row(sourceSets = setOf(sourceset)) {
group(styles = mainStyles + ContentStyle.RowTitle) {
throws.exceptionAddress?.let {
- link(text = it.classNames ?: entry.key, address = it)
+ val className = it.takeIf { it.target is PointingToDeclaration }?.classNames
+ link(text = className ?: entry.key, address = it)
} ?: text(entry.key)
}
if (throws.isNotEmpty()) {