diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-09-29 20:54:59 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-09-29 20:54:59 +0400 |
commit | 778e2b3f7ff62971e18a49d81a8825e5dd894c2e (patch) | |
tree | f7fb9506800262ecabb9050ffee4a97e39812ccb /src/Formats/StructuredFormatService.kt | |
parent | 2e3dc238275073a5c7a2e5a14c79337d12492dad (diff) | |
download | dokka-778e2b3f7ff62971e18a49d81a8825e5dd894c2e.tar.gz dokka-778e2b3f7ff62971e18a49d81a8825e5dd894c2e.tar.bz2 dokka-778e2b3f7ff62971e18a49d81a8825e5dd894c2e.zip |
Extract content model, make doc model independent from descriptors, parse doccomments with custom parser, some tests failing due to hanging new lines.
Diffstat (limited to 'src/Formats/StructuredFormatService.kt')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 0c58f553..b1e614f6 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -28,19 +28,17 @@ public abstract class StructuredFormatService(val locationService: LocationServi public abstract fun formatCode(code: String): String public abstract fun formatBreadcrumbs(items: Iterable<FormatLink>): String - open fun formatText(text: RichString): String { + open fun formatText(nodes: Iterable<ContentNode>): String { + return nodes.map { formatText(it) }.join("") + } + + open fun formatText(text: ContentNode): String { return StringBuilder { - for (slice in text.slices) { - val style = slice.style - when (style) { - is NormalStyle -> append(slice.text) - is BoldStyle -> append(formatBold(slice.text)) - is CodeStyle -> append(formatCode(slice.text)) - is LinkStyle -> { - val node = resolutionService.resolve(style.link) - val location = locationService.location(node) - append(formatLink(slice.text, location)) - } + for (node in text.children) { + when (node) { + is ContentText -> append(node.text) + is ContentEmphasis -> append(formatBold(formatText(node.children))) + else -> append(formatText(node.children)) } } }.toString() @@ -67,7 +65,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi if (label.startsWith("$")) continue appendLine(to, formatBold(formatText(label))) - appendLine(to, formatText(section.text)) + appendLine(to, formatText(section)) appendLine(to) } } |