diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-04-07 16:40:05 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-04-08 11:53:09 +0200 |
commit | 49d69219c9e3cf6307c5be161dc56d04e217d668 (patch) | |
tree | 8a7dd127271a8a84d546a65ae616ec9a8dcacb40 | |
parent | dd645cb5cd77c2738424e445587407b4bf97250c (diff) | |
download | dokka-49d69219c9e3cf6307c5be161dc56d04e217d668.tar.gz dokka-49d69219c9e3cf6307c5be161dc56d04e217d668.tar.bz2 dokka-49d69219c9e3cf6307c5be161dc56d04e217d668.zip |
Resolves problems with multiple DRI resolve in Markdown Parser
-rw-r--r-- | core/src/main/kotlin/parsers/MarkdownParser.kt | 6 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/core/src/main/kotlin/parsers/MarkdownParser.kt b/core/src/main/kotlin/parsers/MarkdownParser.kt index b567bbe7..9354a6b6 100644 --- a/core/src/main/kotlin/parsers/MarkdownParser.kt +++ b/core/src/main/kotlin/parsers/MarkdownParser.kt @@ -12,6 +12,7 @@ import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor import org.jetbrains.dokka.analysis.DokkaResolutionFacade import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.parsers.factories.DocTagsFromIElementFactory +import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag @@ -22,7 +23,8 @@ import org.intellij.markdown.parser.MarkdownParser as IntellijMarkdownParser class MarkdownParser( private val resolutionFacade: DokkaResolutionFacade, - private val declarationDescriptor: DeclarationDescriptor + private val declarationDescriptor: DeclarationDescriptor, + private val logger: DokkaLogger ) : Parser() { inner class MarkdownVisitor(val text: String, val destinationLinksMap: Map<String, String>) { @@ -110,7 +112,7 @@ class MarkdownParser( declarationDescriptor, null, link.split('.') - ).also { if (it.size > 1) throw IllegalStateException("Markdown link resolved more than one element: $it") } + ).also { if (it.size > 1) logger.warn("Markdown link resolved more than one element: $it") } .firstOrNull()//.single() ?.let { DRI.from(it) } } diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index b7dfccd2..0e24fc08 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -11,6 +11,7 @@ import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.parsers.MarkdownParser import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentableTranslator +import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.kotlin.builtins.isExtensionFunctionType import org.jetbrains.kotlin.builtins.isFunctionType import org.jetbrains.kotlin.codegen.isJvmStaticInObjectOrClassOrInterface @@ -40,7 +41,7 @@ class DefaultDescriptorToDocumentableTranslator( moduleName: String, packageFragments: Iterable<PackageFragmentDescriptor>, platformData: PlatformData - ) = DokkaDescriptorVisitor(platformData, context.platforms.getValue(platformData).facade).run { + ) = DokkaDescriptorVisitor(platformData, context.platforms.getValue(platformData).facade, context.logger).run { packageFragments.map { visitPackageFragmentDescriptor( it, @@ -60,7 +61,8 @@ fun DRI.withEmptyInfo() = DRIWithPlatformInfo(this, PlatformDependent.empty()) private class DokkaDescriptorVisitor( private val platformData: PlatformData, - private val resolutionFacade: DokkaResolutionFacade + private val resolutionFacade: DokkaResolutionFacade, + private val logger: DokkaLogger ) : DeclarationDescriptorVisitorEmptyBodies<Documentable, DRIWithPlatformInfo>() { override fun visitDeclarationDescriptor(descriptor: DeclarationDescriptor, parent: DRIWithPlatformInfo): Nothing { throw IllegalStateException("${javaClass.simpleName} should never enter ${descriptor.javaClass.simpleName}") @@ -514,7 +516,7 @@ private class DokkaDescriptorVisitor( toBound().let { if (isMarkedNullable) Nullable(it) else it } private fun DeclarationDescriptor.getDocumentation() = findKDoc().let { - MarkdownParser(resolutionFacade, this).parseFromKDocTag(it) + MarkdownParser(resolutionFacade, this, logger).parseFromKDocTag(it) } private fun ClassDescriptor.companion(dri: DRIWithPlatformInfo): DObject? = companionObjectDescriptor?.let { |