From ef98e4b6505c3fdd192b1d5057c718079d27b972 Mon Sep 17 00:00:00 2001 From: Kamil Doległo <9080183+kamildoleglo@users.noreply.github.com> Date: Tue, 5 Jan 2021 12:19:01 +0100 Subject: Fix a bug with inserting template commands instead of link text (#1685) Some test methods were dropped intentionally, as using them can lead to subtle bugs. The same methods are available in the base-test-utils module --- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'plugins/base/src/main') diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 2a24a959..1584df02 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -1,8 +1,5 @@ package org.jetbrains.dokka.base.renderers.html -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import kotlinx.html.* import kotlinx.html.stream.createHTML import org.jetbrains.dokka.DokkaSourceSetID @@ -644,18 +641,13 @@ open class HtmlRenderer( ) = locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) } ?: run { context.logger.error("Cannot resolve path for `$to` from `$from`"); block() } - override fun buildError(node: ContentNode) { - context.logger.error("Unknown ContentNode type: $node") - } + override fun buildError(node: ContentNode) = context.logger.error("Unknown ContentNode type: $node") - override fun FlowContent.buildNewLine() { - br() - } + override fun FlowContent.buildNewLine() = br() override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) = a(href = address, block = content) - override fun FlowContent.buildDRILink( node: ContentDRILink, pageContext: ContentPage, @@ -664,8 +656,15 @@ open class HtmlRenderer( buildLink(address) { buildText(node.children, pageContext, sourceSetRestriction) } - } ?: templateCommand(ResolveLinkCommand(node.address)) { - buildText(node.children, pageContext, sourceSetRestriction) + } ?: if (isPartial) { + templateCommand(ResolveLinkCommand(node.address)) { + buildText(node.children, pageContext, sourceSetRestriction) + } + } else { + span { + attributes["data-unresolved-link"] = node.address.toString().htmlEscape() + buildText(node.children, pageContext, sourceSetRestriction) + } } override fun FlowContent.buildCodeBlock( @@ -823,6 +822,7 @@ open class HtmlRenderer( (locationProvider as DokkaBaseLocationProvider).anchorForDCI(DCI(dci.dri, contentKind), sourceSets) } + private val isPartial = context.configuration.delayTemplateSubstitution } fun List.joinAttr() = joinToString(" ") { it.extraKey + "=" + it.extraValue } -- cgit