diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2019-11-07 08:21:43 +0100 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2019-11-08 18:47:43 +0100 |
commit | 493951f487910a1306a4129b7e8144e679c0213c (patch) | |
tree | 15ac0502e76c0a327bb835e31d0e65f499928ec1 /core/src/main/kotlin/pages/MarkdownToContentConverter.kt | |
parent | 0627b9dd15171db221bee2e5a6b0082aec813c98 (diff) | |
download | dokka-493951f487910a1306a4129b7e8144e679c0213c.tar.gz dokka-493951f487910a1306a4129b7e8144e679c0213c.tar.bz2 dokka-493951f487910a1306a4129b7e8144e679c0213c.zip |
Moving platform merging to documentationNodes
Diffstat (limited to 'core/src/main/kotlin/pages/MarkdownToContentConverter.kt')
-rw-r--r-- | core/src/main/kotlin/pages/MarkdownToContentConverter.kt | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/core/src/main/kotlin/pages/MarkdownToContentConverter.kt b/core/src/main/kotlin/pages/MarkdownToContentConverter.kt index 24bfc6f4..b29614d7 100644 --- a/core/src/main/kotlin/pages/MarkdownToContentConverter.kt +++ b/core/src/main/kotlin/pages/MarkdownToContentConverter.kt @@ -3,25 +3,21 @@ package org.jetbrains.dokka.pages import org.intellij.markdown.MarkdownElementTypes import org.intellij.markdown.MarkdownTokenTypes import org.jetbrains.dokka.DokkaLogger -import org.jetbrains.dokka.DokkaResolutionFacade import org.jetbrains.dokka.MarkdownNode -import org.jetbrains.dokka.Model.DocumentationNode import org.jetbrains.dokka.links.DRI -import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink class MarkdownToContentConverter( - private val resolutionFacade: DokkaResolutionFacade, private val logger: DokkaLogger ) { fun buildContent( node: MarkdownNode, dci: DCI, - documentationNode: DocumentationNode<*> + links: Map<String, DRI> = emptyMap() ): List<ContentNode> { // println(tree.toTestString()) fun buildChildren(node: MarkdownNode) = node.children.flatMap { - buildContent(it, dci, documentationNode) + buildContent(it, dci, links) }.coalesceText() return when (node.type) { @@ -89,27 +85,15 @@ class MarkdownToContentConverter( } MarkdownElementTypes.SHORT_REFERENCE_LINK, MarkdownElementTypes.FULL_REFERENCE_LINK -> { - if (documentationNode.descriptors.isNotEmpty()) { - val destinationNode = node.children.find { it.type == MarkdownElementTypes.LINK_DESTINATION } - ?: node.children.first { it.type == MarkdownElementTypes.LINK_LABEL } - val destination = destinationNode.children.find { it.type == MarkdownTokenTypes.TEXT }?.text - ?: destinationNode.text - - documentationNode.descriptors.flatMap { - resolveKDocLink( - resolutionFacade.resolveSession.bindingContext, - resolutionFacade, - it, - null, - destination.split('.') - ) - } - .firstOrNull() - ?.let { ContentLink(destination, DRI.from(it), dci) } - .let(::listOfNotNull) - } else { - logger.error("Apparently descriptor for $documentationNode was needed in model") - emptyList() + val destinationNode = node.children.find { it.type == MarkdownElementTypes.LINK_DESTINATION } + ?: node.children.first { it.type == MarkdownElementTypes.LINK_LABEL } + val destination = destinationNode.children.find { it.type == MarkdownTokenTypes.TEXT }?.text + ?: destinationNode.text + links[destination]?.let { dri -> + listOf(ContentLink(destination, dri, dci)) + } ?: let { + logger.error("Apparently there is no link resolved for $destination") + emptyList<ContentNode>() } } MarkdownTokenTypes.WHITE_SPACE -> { |