aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators
diff options
context:
space:
mode:
authormkondratek <mkondratek@virtuslab.com>2020-09-11 21:38:10 +0200
committerAndrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com>2020-09-29 16:04:51 +0200
commit5a214c157e29145b8828b69060ba5111c7f1e166 (patch)
tree3b9829e139ef7d6f998eb3c78e1b4d1b1fc457d7 /plugins/base/src/main/kotlin/translators
parent26415d91fcf32f0c70af4f9cea9500bca8187b0e (diff)
downloaddokka-5a214c157e29145b8828b69060ba5111c7f1e166.tar.gz
dokka-5a214c157e29145b8828b69060ba5111c7f1e166.tar.bz2
dokka-5a214c157e29145b8828b69060ba5111c7f1e166.zip
Add MD parser
Diffstat (limited to 'plugins/base/src/main/kotlin/translators')
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt20
1 files changed, 18 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 68b69719..ecfd5172 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -12,7 +12,6 @@ import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.Nullable
import org.jetbrains.dokka.model.TypeConstructor
import org.jetbrains.dokka.model.doc.*
-import org.jetbrains.dokka.model.properties.ExtraProperty
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator
@@ -30,6 +29,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotated
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies
import org.jetbrains.kotlin.idea.kdoc.findKDoc
+import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
import org.jetbrains.kotlin.load.kotlin.toSourceElement
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
@@ -683,7 +683,23 @@ private class DokkaDescriptorVisitor(
}
private fun DeclarationDescriptor.getDocumentation() = findKDoc().let {
- MarkdownParser(resolutionFacade, this, logger).parseFromKDocTag(it)
+ MarkdownParser.parseFromKDocTag(
+ kDocTag = it,
+ externalDri = { link: String ->
+ try {
+ resolveKDocLink(
+ context = resolutionFacade.resolveSession.bindingContext,
+ resolutionFacade = resolutionFacade,
+ fromDescriptor = this,
+ fromSubjectOfTag = null,
+ qualifiedName = link.split('.')
+ ).firstOrNull()?.let { DRI.from(it) }
+ } catch (e1: IllegalArgumentException) {
+ logger.warn("Couldn't resolve link for $link")
+ null
+ }
+ }
+ )
}.takeIf { it.children.isNotEmpty() }
private fun ClassDescriptor.companion(dri: DRIWithPlatformInfo): DObject? = companionObjectDescriptor?.let {