From 782a0b35513dedc0521bcd3a94204b2cfeb22d3d Mon Sep 17 00:00:00 2001 From: kisenka Date: Fri, 10 Oct 2014 16:12:57 +0400 Subject: Make Jekyll formatter extendable --- src/Formats/JekyllFormatService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Formats/JekyllFormatService.kt b/src/Formats/JekyllFormatService.kt index 9870c8ee..dc18a6e4 100644 --- a/src/Formats/JekyllFormatService.kt +++ b/src/Formats/JekyllFormatService.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka -public class JekyllFormatService(locationService: LocationService, +public open class JekyllFormatService(locationService: LocationService, signatureGenerator: LanguageService) : MarkdownFormatService(locationService, signatureGenerator) { -- cgit From 290d5a950c0909310cef64937dc64c8fd98ff473 Mon Sep 17 00:00:00 2001 From: kisenka Date: Fri, 10 Oct 2014 16:16:34 +0400 Subject: Fix Markdown table syntax. --- src/Formats/MarkdownFormatService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index bbe0d7be..07a6d1f7 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -90,14 +90,14 @@ public open class MarkdownFormatService(locationService: LocationService, } override fun appendTableRow(to: StringBuilder, body: () -> Unit) { - to.append("|") + to.append("| ") body() to.appendln() } override fun appendTableCell(to: StringBuilder, body: () -> Unit) { body() - to.append("|") + to.append(" | ") } var outlineLevel = 0 -- cgit From d3421d01f7fa9b3385b516eae5ae3895a73618de Mon Sep 17 00:00:00 2001 From: kisenka Date: Fri, 10 Oct 2014 20:32:15 +0400 Subject: Change formatter to KotlinWebsiteFormatService --- src/main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.kt b/src/main.kt index d30f3035..970bbd8c 100644 --- a/src/main.kt +++ b/src/main.kt @@ -64,7 +64,7 @@ public fun main(args: Array) { val locationService = FoldersLocationService(arguments.outputDir) val templateService = HtmlTemplateService.default("/dokka/styles/style.css") - val formatter = HtmlFormatService(locationService, signatureGenerator, templateService) + val formatter = KotlinWebsiteFormatService(locationService, signatureGenerator) val generator = FileGenerator(signatureGenerator, locationService, formatter) print("Building pages... ") generator.buildPage(documentation) -- cgit From 8fbeb618bf342dff9e7ba2502bbc07ed50b9806b Mon Sep 17 00:00:00 2001 From: kisenka Date: Fri, 10 Oct 2014 20:33:05 +0400 Subject: Fix code block formating in Markdown formatter --- src/Formats/MarkdownFormatService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index 07a6d1f7..a835a673 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -70,9 +70,11 @@ public open class MarkdownFormatService(locationService: LocationService, } override public fun appendBlockCode(to: StringBuilder, line: String) { - appendLine(to, "```") + appendLine(to) + to.appendln("```") to.appendln(line) - appendLine(to, "```") + to.appendln("```") + appendLine(to) } override fun appendTable(to: StringBuilder, body: () -> Unit) { -- cgit From 18bcaee1e51fe3158ce785a34a6115123b7543ef Mon Sep 17 00:00:00 2001 From: kisenka Date: Fri, 10 Oct 2014 20:33:59 +0400 Subject: Added necessary newline after YAML Frontmatter section in Jekyll formatter --- src/Formats/JekyllFormatService.kt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Formats/JekyllFormatService.kt b/src/Formats/JekyllFormatService.kt index dc18a6e4..5179b37d 100644 --- a/src/Formats/JekyllFormatService.kt +++ b/src/Formats/JekyllFormatService.kt @@ -11,6 +11,7 @@ public open class JekyllFormatService(locationService: LocationService, to.appendln("layout: api") to.appendln("title: ${nodes.first().name}") to.appendln("---") + to.appendln("") super.appendNodes(location, to, nodes) } } \ No newline at end of file -- cgit 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