diff options
author | kisenka <qtuzov@gmail.com> | 2014-10-10 20:34:22 +0400 |
---|---|---|
committer | kisenka <qtuzov@gmail.com> | 2014-10-10 20:34:22 +0400 |
commit | f5d6bc3129e2cd5ba9511415b3e700b22f28c2da (patch) | |
tree | 4a9fbc3ad534df405e17e0d58a0b8a40d2ac4083 /src | |
parent | 18bcaee1e51fe3158ce785a34a6115123b7543ef (diff) | |
download | dokka-f5d6bc3129e2cd5ba9511415b3e700b22f28c2da.tar.gz dokka-f5d6bc3129e2cd5ba9511415b3e700b22f28c2da.tar.bz2 dokka-f5d6bc3129e2cd5ba9511415b3e700b22f28c2da.zip |
Formatter for Kotlin website added
Diffstat (limited to 'src')
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 88 |
1 files changed, 88 insertions, 0 deletions
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<FormatLink>): String { + items.drop(1) + + if (items.count() > 1) { + return "<div class='api-docs-breadcrumbs'>" + + items.map { formatLink(it) }.joinToString(" / ") + + "</div>" + } + + return "" + } + + override fun formatLink(text: String, location: Location): String { + return "<a href=\"${location.path + .replace("\\", "/") + .replaceAfterLast(".","html")}\">${text}</a>" + } + + override fun formatLink(text: String, href: String): String { + return "<a href=\"${href}\">${text}</a>" + } + + override fun appendText(to: StringBuilder, text: String) { + to.appendln("<p markdown=\"1\">${text}</p>") + } + + override fun appendTable(to: StringBuilder, body: () -> Unit) { + to.appendln("<table class=\"api-docs-table\">") + body() + to.appendln("</table>") + } + + override fun appendTableHeader(to: StringBuilder, body: () -> Unit) { + to.appendln("<thead>") + body() + to.appendln("</thead>") + } + + override fun appendTableBody(to: StringBuilder, body: () -> Unit) { + to.appendln("<tbody>") + body() + to.appendln("</tbody>") + } + + override fun appendTableRow(to: StringBuilder, body: () -> Unit) { + to.appendln("<tr>") + body() + to.appendln("</tr>") + } + + override fun appendTableCell(to: StringBuilder, body: () -> Unit) { + to.appendln("<td markdown=\"1\">") + body() + to.appendln("\n</td>") + } + + override public fun appendBlockCode(to: StringBuilder, lines: Iterable<String>) { + to.append("<pre markdown=\"1\">") + for (line in lines) + to.appendln(line) + to.append(to, "</pre>") + } + + override public fun appendBlockCode(to: StringBuilder, line: String) { + to.append("<pre markdown=\"1\">") + to.append(line.trimLeading()) + to.append("</pre>") + } + + override fun formatSymbol(text: String): String { + return "<span class=\"symbol\">${formatText(text)}</span>" + } + + override fun formatKeyword(text: String): String { + return "<span class=\"keyword\">${formatText(text)}</span>" + } + + override fun formatIdentifier(text: String): String { + return "<span class=\"identifier\">${formatText(text)}</span>" + } +}
\ No newline at end of file |