From b593337bc686a942c36a7effd61e00ace388567b Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 23 Jul 2020 16:14:46 +0200 Subject: Fix truncated text on sidebar with long packages --- .../base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 11 +++++++---- .../src/main/kotlin/renderers/html/NavigationPage.kt | 4 ++-- .../main/kotlin/renderers/html/htmlFormatingUtils.kt | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt (limited to 'plugins/base/src/main/kotlin/renderers/html') 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 -- cgit