aboutsummaryrefslogtreecommitdiff
path: root/src/Formats/FormatService.kt
blob: 642fad04a9f7673d3e161b0d93f920263a9bba78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 interface 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>)
}

/** Format content to [String] using specified [location] */
fun FormatService.format(location: Location, nodes: Iterable<DocumentationNode>): String = kotlin.StringBuilder { appendNodes(location, this, nodes) }.toString()