From f65fbf534807c168a81f4e80919680ca7dcff47b Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 24 Mar 2017 22:01:49 +0300 Subject: Tweak kws html format to match output of old format --- core/src/main/kotlin/Formats/HtmlFormatService.kt | 2 +- .../Formats/KotlinWebsiteHtmlFormatService.kt | 19 ++++++----- .../main/kotlin/Formats/StructuredFormatService.kt | 38 +++++++++++++--------- 3 files changed, 34 insertions(+), 25 deletions(-) (limited to 'core/src/main/kotlin/Formats') diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt index 5e05f51a..b6672434 100644 --- a/core/src/main/kotlin/Formats/HtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt @@ -46,7 +46,7 @@ open class HtmlOutputBuilder(to: StringBuilder, override fun appendParagraph(body: () -> Unit) = wrapInTag("p", body, newlineBeforeOpen = true, newlineAfterClose = true) - override fun appendSoftParagraph(body: () -> Unit) = appendParagraph(body) + override fun appendSoftParagraph(body: () -> Unit) = body() override fun appendLine() { to.appendln("
") diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt index 7b9279b2..0d8b10bb 100644 --- a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt @@ -66,14 +66,6 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder, override fun appendLink(href: String, body: () -> Unit) = wrap("", "", body) - override fun appendHeader(level: Int, body: () -> Unit) { - if (insideDiv > 0) { - wrapInTag("p", body, newlineAfterClose = true) - } else { - super.appendHeader(level, body) - } - } - override fun appendTable(vararg columns: String, body: () -> Unit) { to.appendln("") body() @@ -164,6 +156,17 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder, } } } + + override fun appendSoftParagraph(body: () -> Unit) = appendParagraph(body) + + + override fun appendSectionWithTag(section: ContentSection) { + appendParagraph { + appendStrong { appendText(section.tag) } + appendText(" ") + appendContent(section) + } + } } class KotlinWebsiteHtmlFormatService @Inject constructor(locationService: LocationService, diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index 961c2c26..b29cf492 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -73,6 +73,14 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } } + open fun appendSectionWithTag(section: ContentSection) { + appendParagraph { + appendStrong { appendText(section.tag) } + appendLine() + appendContent(section) + } + } + open fun appendSymbol(text: String) { appendText(text) } @@ -294,11 +302,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, formatOverloadGroup(breakdownBySummary.values.single()) } else { for ((_, items) in breakdownBySummary) { - appendSoftParagraph { - appendAsOverloadGroup(to, platformsOfItems(items)) { - formatOverloadGroup(items) - } + + appendAsOverloadGroup(to, platformsOfItems(items)) { + formatOverloadGroup(items) } + } } } @@ -408,11 +416,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } for (section in content.sections.filter { it.subjectName == null }) { - appendParagraph { - appendStrong { appendText(section.tag) } - appendLine() - appendContent(section) - } + appendSectionWithTag(section) } } @@ -450,11 +454,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } for (member in node.members.sortedBy(DocumentationNode::priority)) { - appendSoftParagraph { - appendAsOverloadGroup(to, platformsOfItems(listOf(member))) { - formatSubNodeOfGroup(member) - } + + appendAsOverloadGroup(to, platformsOfItems(listOf(member))) { + formatSubNodeOfGroup(member) } + } } @@ -559,9 +563,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, elementPlatforms appendIndexRow(platforms) { appendTableCell { - appendLink(memberLocation) - if (members.singleOrNull()?.kind != NodeKind.ExternalClass) { - appendPlatforms(platforms) + appendParagraph { + appendLink(memberLocation) + if (members.singleOrNull()?.kind != NodeKind.ExternalClass) { + appendPlatforms(platforms) + } } } appendTableCell { -- cgit