diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-07-29 11:27:07 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-19 13:34:10 +0200 |
commit | b072356193b98bd34c688c21611180ea68c7f32c (patch) | |
tree | db5810dc569a4f767209bb203b2d62b3c5d88932 /plugins | |
parent | ab9bcc534768e9886a308bd567219cd8a3208bb1 (diff) | |
download | dokka-b072356193b98bd34c688c21611180ea68c7f32c.tar.gz dokka-b072356193b98bd34c688c21611180ea68c7f32c.tar.bz2 dokka-b072356193b98bd34c688c21611180ea68c7f32c.zip |
Wrap unresolved links in `span` with `data-unresolved-link`
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt | 33 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 14 |
2 files changed, 38 insertions, 9 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index fe2913a4..d9ff924b 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -108,15 +108,8 @@ abstract class DefaultRenderer<T>( is ContentHeader -> buildHeader(node, pageContext, sourceSetRestriction) is ContentCodeBlock -> buildCodeBlock(node, pageContext) is ContentCodeInline -> buildCodeInline(node, pageContext) - is ContentDRILink -> - locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address -> - buildLink(address) { - buildText(node.children, pageContext, sourceSetRestriction) - } - } ?: buildText(node.children, pageContext, sourceSetRestriction) - is ContentResolvedLink -> buildLink(node.address) { - buildText(node.children, pageContext, sourceSetRestriction) - } + is ContentDRILink -> buildDRILink(node, pageContext, sourceSetRestriction) + is ContentResolvedLink -> buildResolvedLink(node, pageContext, sourceSetRestriction) is ContentEmbeddedResource -> buildResource(node, pageContext) is ContentList -> buildList(node, pageContext, sourceSetRestriction) is ContentTable -> buildTable(node, pageContext, sourceSetRestriction) @@ -130,6 +123,28 @@ abstract class DefaultRenderer<T>( } } + open fun T.buildDRILink( + node: ContentDRILink, + pageContext: ContentPage, + sourceSetRestriction: Set<DokkaSourceSet>? + ) { + locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address -> + buildLink(address) { + buildText(node.children, pageContext, sourceSetRestriction) + } + } ?: buildText(node.children, pageContext, sourceSetRestriction) + } + + open fun T.buildResolvedLink( + node: ContentResolvedLink, + pageContext: ContentPage, + sourceSetRestriction: Set<DokkaSourceSet>? + ) { + buildLink(node.address) { + buildText(node.children, pageContext, sourceSetRestriction) + } + } + open fun T.buildDivergentInstance(node: ContentDivergentInstance, pageContext: ContentPage) { node.before?.build(this, pageContext) node.divergent.build(this, pageContext) diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 1a2a98b3..e3d54e49 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -563,6 +563,20 @@ open class HtmlRenderer( override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) = a(href = address, block = content) + + override fun FlowContent.buildDRILink( + node: ContentDRILink, + pageContext: ContentPage, + sourceSetRestriction: Set<DokkaSourceSet>? + ) = locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address -> + buildLink(address) { + buildText(node.children, pageContext, sourceSetRestriction) + } + } ?: span { + attributes["data-unresolved-link"] = "true" + buildText(node.children, pageContext, sourceSetRestriction) + } + override fun FlowContent.buildCodeBlock( code: ContentCodeBlock, pageContext: ContentPage |