aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-07-22 14:29:25 +0200
committerGitHub <noreply@github.com>2021-07-22 14:29:25 +0200
commitbb712835958c823e06db8c39c0a1d32493f095b8 (patch)
tree3404f71e2014c1b6ab3edb566be32caaa5ed9db3 /plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
parentb6dce5370b0c90932127499a903453b199e69c5a (diff)
downloaddokka-bb712835958c823e06db8c39c0a1d32493f095b8.tar.gz
dokka-bb712835958c823e06db8c39c0a1d32493f095b8.tar.bz2
dokka-bb712835958c823e06db8c39c0a1d32493f095b8.zip
Fix overflow in throws tables (#2028)
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt32
1 files changed, 24 insertions, 8 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
index 65bf59fa..b9eab293 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
@@ -13,7 +13,7 @@ fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String) {
buildBreakableText(withOutSpaces.last())
} else {
val content = name.replace(Regex("(?!^)([A-Z])"), " $1").split(" ")
- joinToHtml(content){
+ joinToHtml(content) {
it
}
}
@@ -21,20 +21,36 @@ fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String) {
fun FlowContent.buildBreakableDotSeparatedHtml(name: String) {
val phrases = name.split(".")
- joinToHtml(phrases){
- "$it."
+ phrases.forEachIndexed { i, e ->
+ if (e.length > 10) {
+ buildBreakableText(e)
+ } else {
+ val elementWithOptionalDot =
+ if (i != phrases.lastIndex) {
+ "$e."
+ } else {
+ e
+ }
+ buildBreakableHtmlElement(elementWithOptionalDot)
+ }
}
}
private fun FlowContent.joinToHtml(elements: List<String>, onEach: (String) -> String) {
elements.dropLast(1).forEach {
- span {
- +onEach(it)
- }
- wbr { }
+ buildBreakableHtmlElement(onEach(it))
}
span {
- +elements.last()
+ buildBreakableHtmlElement(elements.last(), last = true)
+ }
+}
+
+private fun FlowContent.buildBreakableHtmlElement(element: String, last: Boolean = false) {
+ span {
+ +element
+ }
+ if (!last) {
+ wbr { }
}
}