aboutsummaryrefslogtreecommitdiff
path: root/src/Formats/MarkdownFormatService.kt
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-15 16:18:53 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-15 16:18:53 +0400
commit499d082186fcda877a216d536cf9512d0f0265ac (patch)
treef82c8c5e19cc5c37e4fc3b37706a988fa32b173a /src/Formats/MarkdownFormatService.kt
parent62cb509a1a5adf0e5f9ba8d8e7545a93eb8516b2 (diff)
downloaddokka-499d082186fcda877a216d536cf9512d0f0265ac.tar.gz
dokka-499d082186fcda877a216d536cf9512d0f0265ac.tar.bz2
dokka-499d082186fcda877a216d536cf9512d0f0265ac.zip
Cleaning, generalizing, added outline support (hardcoded yml for now)
Diffstat (limited to 'src/Formats/MarkdownFormatService.kt')
-rw-r--r--src/Formats/MarkdownFormatService.kt27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt
index 2a91a4a3..6a76343d 100644
--- a/src/Formats/MarkdownFormatService.kt
+++ b/src/Formats/MarkdownFormatService.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka
-public open class MarkdownFormatService(locationService: LocationService, signatureGenerator: SignatureGenerator)
+public open class MarkdownFormatService(locationService: LocationService, signatureGenerator: LanguageService)
: StructuredFormatService(locationService, signatureGenerator) {
override val extension: String = "md"
@@ -18,8 +18,8 @@ public open class MarkdownFormatService(locationService: LocationService, signat
return "**$text**"
}
- override public fun formatLink(link: FormatLink): String {
- return "[${link.text}](${link.location.path})"
+ override public fun formatLink(text: String, location: Location): String {
+ return "[${text}](${location.path})"
}
override public fun appendLine(to: StringBuilder) {
@@ -52,4 +52,25 @@ public open class MarkdownFormatService(locationService: LocationService, signat
appendLine(to, line)
appendLine(to, "```")
}
+
+ var outlineLevel = 0
+ override fun appendOutlineHeader(to: StringBuilder, node: DocumentationNode) {
+ val indent = " ".repeat(outlineLevel)
+ appendLine(to, "$indent- title: ${languageService.renderName(node)}")
+ appendLine(to, "$indent url: ${locationService.location(node).path}")
+ }
+
+ override fun appendOutlineChildren(to: StringBuilder, nodes: Iterable<DocumentationNode>) {
+ val indent = " ".repeat(outlineLevel)
+ appendLine(to, "$indent content:")
+ outlineLevel++
+ for (node in nodes) {
+ appendOutlineHeader(to, node)
+ if (node.members.any()) {
+ appendOutlineChildren(to, node.members)
+ }
+ appendLine(to)
+ }
+ outlineLevel--
+ }
}