diff options
author | Marcin Aman <maman@virtuslab.com> | 2020-07-23 16:14:46 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-29 13:58:18 +0200 |
commit | b593337bc686a942c36a7effd61e00ace388567b (patch) | |
tree | 1e00f512b48df071c0e3102a038af040f59f2e75 /plugins/base/src/main/kotlin/renderers/html | |
parent | c3493ccf44f7d5bb99467ef66d84a11322a9c848 (diff) | |
download | dokka-b593337bc686a942c36a7effd61e00ace388567b.tar.gz dokka-b593337bc686a942c36a7effd61e00ace388567b.tar.bz2 dokka-b593337bc686a942c36a7effd61e00ace388567b.zip |
Fix truncated text on sidebar with long packages
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html')
3 files changed, 26 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 614d8f6e..d25bedb7 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -618,12 +618,15 @@ open class HtmlRenderer( } } - override fun FlowContent.buildText(textNode: ContentText) { + override fun FlowContent.buildText(textNode: ContentText) = when { - textNode.hasStyle(TextStyle.Indented) -> consumer.onTagContentEntity(Entities.nbsp) + textNode.hasStyle(TextStyle.Indented) -> { + consumer.onTagContentEntity(Entities.nbsp) + text(textNode.text) + } + textNode.hasStyle(TextStyle.Cover) -> buildBreakableDotSeparatedHtml(textNode.text) + else -> text(textNode.text) } - text(textNode.text) - } private fun generatePagesList() = pageList.entries diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index 8fe2a6c8..46295d71 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -25,9 +25,9 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage { id = navId attributes["pageId"] = node.dri.toString() div("overview") { - buildLink(node.dri, node.sourceSets.toList()) { +node.name } + buildLink(node.dri, node.sourceSets.toList()) { buildBreakableDotSeparatedHtml(node.name) } if (node.children.isNotEmpty()) { - span("navButton") { + span("navButton pull-right") { onClick = """document.getElementById("$navId").classList.toggle("hidden");""" span("navButtonContent") } diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt new file mode 100644 index 00000000..1102b86d --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt @@ -0,0 +1,17 @@ +package org.jetbrains.dokka.base.renderers.html + +import kotlinx.html.FlowContent +import kotlinx.html.span + +fun FlowContent.buildBreakableDotSeparatedHtml(name: String) { + val phrases = name.split(".") + phrases.dropLast(1).forEach { + span { + +"$it." + } + wbr { } + } + span { + +phrases.last() + } +}
\ No newline at end of file |