aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Formats/JekyllFormatService.kt3
-rw-r--r--src/Formats/KotlinWebsiteFormatService.kt88
-rw-r--r--src/Formats/MarkdownFormatService.kt10
-rw-r--r--src/main.kt2
4 files changed, 97 insertions, 6 deletions
diff --git a/src/Formats/JekyllFormatService.kt b/src/Formats/JekyllFormatService.kt
index 9870c8ee..5179b37d 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) {
@@ -11,6 +11,7 @@ public class JekyllFormatService(locationService: LocationService,
to.appendln("layout: api")
to.appendln("title: ${nodes.first().name}")
to.appendln("---")
+ to.appendln("")
super<MarkdownFormatService>.appendNodes(location, to, nodes)
}
} \ No newline at end of file
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
diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt
index bbe0d7be..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) {
@@ -90,14 +92,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
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<String>) {
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)