diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-27 18:37:35 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 11:57:20 +0100 |
commit | 8291bee3a86f5f2409ba4ae44c87f291c664ac19 (patch) | |
tree | a0a4558c4c48184ed630dc62d34f8898f7546b44 /src/Formats/KotlinWebsiteFormatService.kt | |
parent | 3faa3f2d1c7ca33ad8d98bc6c562e4fe6977225f (diff) | |
download | dokka-8291bee3a86f5f2409ba4ae44c87f291c664ac19.tar.gz dokka-8291bee3a86f5f2409ba4ae44c87f291c664ac19.tar.bz2 dokka-8291bee3a86f5f2409ba4ae44c87f291c664ac19.zip |
wrapping and nicer formatting for signatures
Diffstat (limited to 'src/Formats/KotlinWebsiteFormatService.kt')
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index 97419c58..b66fa1a7 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -3,6 +3,8 @@ package org.jetbrains.dokka public class KotlinWebsiteFormatService(locationService: LocationService, signatureGenerator: LanguageService) : JekyllFormatService(locationService, signatureGenerator) { + private var needHardLineBreaks = false + override fun appendFrontMatter(nodes: Iterable<DocumentationNode>, to: StringBuilder) { super.appendFrontMatter(nodes, to) to.appendln("layout: api") @@ -24,12 +26,17 @@ public class KotlinWebsiteFormatService(locationService: LocationService, override fun formatStrikethrough(text: String): String = "<s>$text</s>" - override fun appendAsSignature(to: StringBuilder, block: () -> Unit) { - val oldLength = to.length - block() - if (to.length > oldLength) { - to.append("<br/>") // since we've used HTML to format the signature, add an HTML line break following it + override fun appendAsSignature(to: StringBuilder, node: ContentNode, block: () -> Unit) { + val contentLength = node.textLength + if (contentLength == 0) return + to.append("<div class=\"signature\">") + needHardLineBreaks = contentLength >= 62 + try { + block() + } finally { + needHardLineBreaks = false } + to.append("</div>") } override fun formatLink(text: String, href: String): String { @@ -88,6 +95,16 @@ public class KotlinWebsiteFormatService(locationService: LocationService, return "<span class=\"${identifierClassName(kind)}\">${formatText(text)}</span>" } + override fun formatSoftLineBreak(): String = if (needHardLineBreaks) + "<br/>" + else + "" + + override fun formatIndentedSoftLineBreak(): String = if (needHardLineBreaks) + "<br/> " + else + "" + private fun identifierClassName(kind: IdentifierKind) = when(kind) { IdentifierKind.ParameterName -> "parameterName" IdentifierKind.SummarizedTypeName -> "summarizedTypeName" |