From f90ee50fcace48d71b132d6ec7f305138fe01e44 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 26 Feb 2015 13:55:37 +0100 Subject: fix formatting of signatures in Kotlin web site --- src/Formats/KotlinWebsiteFormatService.kt | 6 +++++- src/Formats/StructuredFormatService.kt | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/Formats') diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index 3096c9de..dd33f5c4 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -20,11 +20,15 @@ public class KotlinWebsiteFormatService(locationService: LocationService, return "" } - override public fun formatCode(code: String): String = "$code" override fun formatStrikethrough(text: String): String = "$text" + override fun appendAsSignature(to: StringBuilder, block: () -> Unit) { + block() + to.append("
") // since we've used HTML to format the signature, add an HTML line break following it + } + override fun formatLink(text: String, href: String): String { return "${text}" } diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 00ec6db4..8d817b19 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -96,8 +96,10 @@ public abstract class StructuredFormatService(locationService: LocationService, for ((summary, items) in breakdownBySummary) { items.forEach { - to.append(formatCode(formatText(location, languageService.render(it)))) - it.appendSourceLink(to) + appendAsSignature(to) { + to.append(formatCode(formatText(location, languageService.render(it)))) + it.appendSourceLink(to) + } it.appendOverrides(to) it.appendDeprecation(location, to) } @@ -110,6 +112,10 @@ public abstract class StructuredFormatService(locationService: LocationService, } } + protected open fun appendAsSignature(to: StringBuilder, block: () -> Unit) { + block() + } + fun appendDescription(location: Location, to: StringBuilder, node: DocumentationNode) { if (node.content.description != ContentEmpty) { appendHeader(to, "Description", 3) @@ -210,7 +216,9 @@ public abstract class StructuredFormatService(locationService: LocationService, signatureTexts.subList(0, signatureTexts.size()-1).forEach { appendLine(to, it) } - to.append(signatureTexts.last()) + appendAsSignature(to) { + to.append(signatureTexts.last()) + } if (!summary.isEmpty()) { to.append(summary) } -- cgit