From f5d6bc3129e2cd5ba9511415b3e700b22f28c2da Mon Sep 17 00:00:00 2001 From: kisenka Date: Fri, 10 Oct 2014 20:34:22 +0400 Subject: Formatter for Kotlin website added --- src/Formats/KotlinWebsiteFormatService.kt | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/Formats/KotlinWebsiteFormatService.kt (limited to 'src') diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt new file mode 100644 index 00000000..9fee14ff --- /dev/null +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -0,0 +1,88 @@ +package org.jetbrains.dokka + +public class KotlinWebsiteFormatService(locationService: LocationService, + signatureGenerator: LanguageService) +: JekyllFormatService(locationService, signatureGenerator) { + override val extension: String = "md" + + override public fun formatBreadcrumbs(items: Iterable): String { + items.drop(1) + + if (items.count() > 1) { + return "
" + + items.map { formatLink(it) }.joinToString(" / ") + + "
" + } + + return "" + } + + override fun formatLink(text: String, location: Location): String { + return "${text}" + } + + override fun formatLink(text: String, href: String): String { + return "${text}" + } + + override fun appendText(to: StringBuilder, text: String) { + to.appendln("

${text}

") + } + + override fun appendTable(to: StringBuilder, body: () -> Unit) { + to.appendln("") + body() + to.appendln("
") + } + + override fun appendTableHeader(to: StringBuilder, body: () -> Unit) { + to.appendln("") + body() + to.appendln("") + } + + override fun appendTableBody(to: StringBuilder, body: () -> Unit) { + to.appendln("") + body() + to.appendln("") + } + + override fun appendTableRow(to: StringBuilder, body: () -> Unit) { + to.appendln("") + body() + to.appendln("") + } + + override fun appendTableCell(to: StringBuilder, body: () -> Unit) { + to.appendln("") + body() + to.appendln("\n") + } + + override public fun appendBlockCode(to: StringBuilder, lines: Iterable) { + to.append("
")
+        for (line in lines)
+            to.appendln(line)
+        to.append(to, "
") + } + + override public fun appendBlockCode(to: StringBuilder, line: String) { + to.append("
")
+        to.append(line.trimLeading())
+        to.append("
") + } + + override fun formatSymbol(text: String): String { + return "${formatText(text)}" + } + + override fun formatKeyword(text: String): String { + return "${formatText(text)}" + } + + override fun formatIdentifier(text: String): String { + return "${formatText(text)}" + } +} \ No newline at end of file -- cgit