aboutsummaryrefslogtreecommitdiff
path: root/src/Formats/KotlinWebsiteFormatService.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-10-27 18:37:35 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-10-29 11:57:20 +0100
commit8291bee3a86f5f2409ba4ae44c87f291c664ac19 (patch)
treea0a4558c4c48184ed630dc62d34f8898f7546b44 /src/Formats/KotlinWebsiteFormatService.kt
parent3faa3f2d1c7ca33ad8d98bc6c562e4fe6977225f (diff)
downloaddokka-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.kt27
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/>&nbsp;&nbsp;&nbsp;&nbsp;"
+ else
+ ""
+
private fun identifierClassName(kind: IdentifierKind) = when(kind) {
IdentifierKind.ParameterName -> "parameterName"
IdentifierKind.SummarizedTypeName -> "summarizedTypeName"