diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-07-22 14:29:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-22 14:29:25 +0200 |
commit | bb712835958c823e06db8c39c0a1d32493f095b8 (patch) | |
tree | 3404f71e2014c1b6ab3edb566be32caaa5ed9db3 /plugins/base/src/main | |
parent | b6dce5370b0c90932127499a903453b199e69c5a (diff) | |
download | dokka-bb712835958c823e06db8c39c0a1d32493f095b8.tar.gz dokka-bb712835958c823e06db8c39c0a1d32493f095b8.tar.bz2 dokka-bb712835958c823e06db8c39c0a1d32493f095b8.zip |
Fix overflow in throws tables (#2028)
Diffstat (limited to 'plugins/base/src/main')
3 files changed, 28 insertions, 11 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index a6eec0b9..d63e8da6 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -714,13 +714,14 @@ open class HtmlRenderer( consumer.onTagContentEntity(Entities.nbsp) buildText(textNode, unappliedStyles - TextStyle.Indented) } - unappliedStyles.size == 1 && unappliedStyles.contains(TextStyle.Cover) -> buildBreakableText(textNode.text) unappliedStyles.isNotEmpty() -> { val styleToApply = unappliedStyles.first() applyStyle(styleToApply){ buildText(textNode, unappliedStyles - styleToApply) } } + textNode.hasStyle(ContentStyle.RowTitle) || textNode.hasStyle(TextStyle.Cover) -> + buildBreakableText(textNode.text) else -> text(textNode.text) } } 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 { } } } diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index c611927c..61fbd7d2 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -452,7 +452,7 @@ open class DefaultPageCreator( fun DocumentableContentBuilder.contentForThrows() { val throws = tags.withTypeNamed<Throws>() if (throws.isNotEmpty()) { - header(4, "Throws") + header(2, "Throws") sourceSetDependentHint(sourceSets = platforms.toSet(), kind = ContentKind.SourceSetDependentHint) { platforms.forEach { sourceset -> table(kind = ContentKind.Main, sourceSets = setOf(sourceset)) { @@ -615,7 +615,7 @@ open class DefaultPageCreator( styles = emptySet(), extra = elementName?.let { name -> extra + SymbolAnchorHint(name, kind) } ?: extra ) { - link(elementName.orEmpty(), elements.first().dri, kind = kind) + link(elementName.orEmpty(), elements.first().dri, kind = kind, styles = setOf(ContentStyle.RowTitle)) divergentGroup( ContentDivergentGroup.GroupID(name), elements.map { it.dri }.toSet(), |