diff options
Diffstat (limited to 'plugins/base/src')
4 files changed, 31 insertions, 14 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(), diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt index 300e99d2..26c072fd 100644 --- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt +++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt @@ -446,7 +446,7 @@ class ContentForParamsTest : BaseAbstractTest() { } after { group { pWrapped("a normal comment") } - header(4) { +"Throws" } + header(2) { +"Throws" } platformHinted { table { group { @@ -505,7 +505,7 @@ class ContentForParamsTest : BaseAbstractTest() { } after { group { pWrapped("a normal comment") } - header(4) { +"Throws" } + header(2) { +"Throws" } platformHinted { table { group { @@ -585,7 +585,7 @@ class ContentForParamsTest : BaseAbstractTest() { } after { group { pWrapped("a normal comment") } - header(4) { +"Throws" } + header(2) { +"Throws" } platformHinted { table { group { |