From 499d082186fcda877a216d536cf9512d0f0265ac Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Tue, 15 Jul 2014 16:18:53 +0400 Subject: Cleaning, generalizing, added outline support (hardcoded yml for now) --- src/Formats/MarkdownFormatService.kt | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/Formats/MarkdownFormatService.kt') 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) { + 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-- + } } -- cgit