diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-15 16:18:53 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-15 16:18:53 +0400 |
commit | 499d082186fcda877a216d536cf9512d0f0265ac (patch) | |
tree | f82c8c5e19cc5c37e4fc3b37706a988fa32b173a /src/Formats/StructuredFormatService.kt | |
parent | 62cb509a1a5adf0e5f9ba8d8e7545a93eb8516b2 (diff) | |
download | dokka-499d082186fcda877a216d536cf9512d0f0265ac.tar.gz dokka-499d082186fcda877a216d536cf9512d0f0265ac.tar.bz2 dokka-499d082186fcda877a216d536cf9512d0f0265ac.zip |
Cleaning, generalizing, added outline support (hardcoded yml for now)
Diffstat (limited to 'src/Formats/StructuredFormatService.kt')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index a490df67..bca53f4f 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -6,7 +6,7 @@ import org.jetbrains.dokka.DocumentationNode.Kind public data class FormatLink(val text: String, val location: Location) public abstract class StructuredFormatService(val locationService: LocationService, - val signatureGenerator: SignatureGenerator) : FormatService { + val languageService: LanguageService) : FormatService { abstract public fun appendBlockCode(to: StringBuilder, line: String) abstract public fun appendBlockCode(to: StringBuilder, lines: Iterable<String>) @@ -14,7 +14,10 @@ public abstract class StructuredFormatService(val locationService: LocationServi abstract public fun appendText(to: StringBuilder, text: String) abstract public fun appendLine(to: StringBuilder, text: String) public abstract fun appendLine(to: StringBuilder) - public abstract fun formatLink(link: FormatLink): String + + public abstract fun formatLink(text: String, location: Location): String + public open fun formatLink(link: FormatLink): String = formatLink(link.text, link.location) + public abstract fun formatBold(text: String): String public abstract fun formatCode(code: String): String public abstract fun formatBreadcrumbs(items: Iterable<FormatLink>): String @@ -30,7 +33,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi if (described.any()) { appendHeader(to, "Description") for (node in described) { - appendBlockCode(to, signatureGenerator.render(node)) + appendBlockCode(to, languageService.render(node)) appendLine(to, node.doc.description) appendLine(to) for (section in node.doc.sections) { @@ -49,7 +52,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi for ((summary, items) in breakdownBySummary) { appendLine(to, summary) - appendBlockCode(to, items.map { signatureGenerator.render(it) }) + appendBlockCode(to, items.map { languageService.render(it) }) } } @@ -86,7 +89,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi val mainMember = members.first() val displayName = when (mainMember.kind) { Kind.Constructor -> "*.init*" - else -> signatureGenerator.renderName(mainMember).htmlEscape() + else -> languageService.renderName(mainMember).htmlEscape() } appendText(to, "|${formatLink(location)}|") @@ -94,7 +97,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi val breakdownBySummary = members.groupByTo(LinkedHashMap()) { it.doc.summary } for ((summary, items) in breakdownBySummary) { appendLine(to, summary) - appendBlockCode(to, items.map { formatBold("${signatureGenerator.render(it)}") }) + appendBlockCode(to, items.map { formatBold("${languageService.render(it)}") }) } appendLine(to, "|") @@ -104,4 +107,15 @@ public abstract class StructuredFormatService(val locationService: LocationServi } } + abstract public fun appendOutlineHeader(to: StringBuilder, node: DocumentationNode) + abstract public fun appendOutlineChildren(to: StringBuilder, nodes: Iterable<DocumentationNode>) + + override public fun appendOutline(to: StringBuilder, nodes: Iterable<DocumentationNode>) { + for (node in nodes) { + appendOutlineHeader(to, node) + if (node.members.any()) { + appendOutlineChildren(to, node.members) + } + } + } }
\ No newline at end of file |