aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-07-23 16:14:46 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-29 13:58:18 +0200
commitb593337bc686a942c36a7effd61e00ace388567b (patch)
tree1e00f512b48df071c0e3102a038af040f59f2e75 /plugins/base/src/main/kotlin/renderers
parentc3493ccf44f7d5bb99467ef66d84a11322a9c848 (diff)
downloaddokka-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')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt11
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt17
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