aboutsummaryrefslogtreecommitdiff
path: root/src/Formats
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-09-29 20:54:59 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-09-29 20:54:59 +0400
commit778e2b3f7ff62971e18a49d81a8825e5dd894c2e (patch)
treef7fb9506800262ecabb9050ffee4a97e39812ccb /src/Formats
parent2e3dc238275073a5c7a2e5a14c79337d12492dad (diff)
downloaddokka-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')
-rw-r--r--src/Formats/MarkdownFormatService.kt4
-rw-r--r--src/Formats/StructuredFormatService.kt24
-rw-r--r--src/Formats/TextFormatService.kt3
3 files changed, 11 insertions, 20 deletions
diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt
index d7530a25..3b87835f 100644
--- a/src/Formats/MarkdownFormatService.kt
+++ b/src/Formats/MarkdownFormatService.kt
@@ -16,10 +16,6 @@ public open class MarkdownFormatService(locationService: LocationService,
return text.htmlEscape()
}
- override public fun formatText(text: RichString): String {
- return text.toString().htmlEscape()
- }
-
override public fun formatCode(code: String): String {
return "`$code`"
}
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)
}
}
diff --git a/src/Formats/TextFormatService.kt b/src/Formats/TextFormatService.kt
index 77a0bb65..8fea5a6a 100644
--- a/src/Formats/TextFormatService.kt
+++ b/src/Formats/TextFormatService.kt
@@ -9,12 +9,9 @@ public class TextFormatService(val signatureGenerator: LanguageService) : Format
appendln(signatureGenerator.render(node))
appendln()
appendln(node.doc.summary)
- for (n in 0..node.doc.summary.length())
- append("=")
for ((label,section) in node.doc.sections) {
appendln(label)
- appendln(section.text)
}
}
}