diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-12-22 09:50:17 +0200 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-12-22 09:50:17 +0200 |
commit | 18399493263820cf6098603025802ddf862f1920 (patch) | |
tree | b8c915c272cdc484df2b511ad50a9ff829c33612 /src/Formats | |
parent | bd6cddd932c308519ce386197b93de145462bec2 (diff) | |
download | dokka-18399493263820cf6098603025802ddf862f1920.tar.gz dokka-18399493263820cf6098603025802ddf862f1920.tar.bz2 dokka-18399493263820cf6098603025802ddf862f1920.zip |
Document some types in Dokka and fix to make them work.
Diffstat (limited to 'src/Formats')
-rw-r--r-- | src/Formats/FormatService.kt | 16 | ||||
-rw-r--r-- | src/Formats/HtmlFormatService.kt | 8 | ||||
-rw-r--r-- | src/Formats/MarkdownFormatService.kt | 8 | ||||
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 5 |
4 files changed, 37 insertions, 0 deletions
diff --git a/src/Formats/FormatService.kt b/src/Formats/FormatService.kt index 9af74590..bb6da985 100644 --- a/src/Formats/FormatService.kt +++ b/src/Formats/FormatService.kt @@ -1,10 +1,26 @@ package org.jetbrains.dokka +/** + * Abstract representation of a formatting service used to output documentation in desired format + * + * Bundled Formatters: + * * [HtmlFormatService] – outputs documentation to HTML format + * * [MarkdownFormatService] – outputs documentation in Markdown format + * * [TextFormatService] – outputs documentation in Text format + */ public trait FormatService { + /** Returns extension for output files */ val extension: String + + /** Appends formatted content to [StringBuilder](to) using specified [location] */ fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) + + /** Appends formatted outline to [StringBuilder](to) using specified [location] */ fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) } +/** Format content to [String] using specified [location] */ fun FormatService.format(location: Location, nodes: Iterable<DocumentationNode>): String = StringBuilder { appendNodes(location, this, nodes) }.toString() + +/** Format outline to [String] using specified [location] */ fun FormatService.formatOutline(location: Location, nodes: Iterable<DocumentationNode>): String = StringBuilder { appendOutline(location, this, nodes) }.toString()
\ No newline at end of file diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt index c337b69b..48291b48 100644 --- a/src/Formats/HtmlFormatService.kt +++ b/src/Formats/HtmlFormatService.kt @@ -97,6 +97,14 @@ public open class HtmlFormatService(locationService: LocationService, return "<code>${code.htmlEscape()}</code>" } + override fun formatList(text: String): String { + return "<ul>${text}</ul>" + } + + override fun formatListItem(text: String): String { + return "<li>${text}</li>" + } + override fun formatBreadcrumbs(items: Iterable<FormatLink>): String { return items.map { formatLink(it) }.joinToString(" / ") } diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index 8f9699c2..9849c674 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -30,6 +30,14 @@ public open class MarkdownFormatService(locationService: LocationService, return "`$code`" } + override public fun formatList(text: String): String { + return text + } + + override fun formatListItem(text: String): String { + return "* $text" + } + override public fun formatStrong(text: String): String { return "**$text**" } diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 740f6b6a..08b7e55d 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -30,6 +30,8 @@ public abstract class StructuredFormatService(val locationService: LocationServi public abstract fun formatStrong(text: String): String public abstract fun formatEmphasis(text: String): String public abstract fun formatCode(code: String): String + public abstract fun formatList(text: String): String + public abstract fun formatListItem(text: String): String public abstract fun formatBreadcrumbs(items: Iterable<FormatLink>): String open fun formatText(location: Location, nodes: Iterable<ContentNode>): String { @@ -46,6 +48,9 @@ public abstract class StructuredFormatService(val locationService: LocationServi is ContentStrong -> append(formatStrong(formatText(location, content.children))) is ContentCode -> append(formatCode(formatText(location, content.children))) is ContentEmphasis -> append(formatEmphasis(formatText(location, content.children))) + is ContentList -> append(formatList(formatText(location, content.children))) + is ContentListItem -> append(formatListItem(formatText(location, content.children))) + is ContentNodeLink -> { val linkTo = locationService.relativeLocation(location, content.node, extension) val linkText = formatText(location, content.children) |