1 package org.jetbrains.dokka 2 3 /** 4 * Abstract representation of a formatting service used to output documentation in desired format 5 * 6 * Bundled Formatters: 7 * * [HtmlFormatService] – outputs documentation to HTML format 8 * * [MarkdownFormatService] – outputs documentation in Markdown format 9 */ 10 interface FormatService { 11 /** Returns extension for output files */ 12 val extension: String 13 14 /** extension which will be used for internal and external linking */ 15 val linkExtension: String 16 get() = extension 17 createOutputBuildernull18 fun createOutputBuilder(to: StringBuilder, location: Location): FormattedOutputBuilder 19 20 fun enumerateSupportFiles(callback: (resource: String, targetPath: String) -> Unit) { 21 } 22 } 23 24 interface FormattedOutputBuilder { 25 /** Appends formatted content to [StringBuilder](to) using specified [location] */ appendNodesnull26 fun appendNodes(nodes: Iterable<DocumentationNode>) 27 } 28 29 /** Format content to [String] using specified [location] */ 30 fun FormatService.format(location: Location, nodes: Iterable<DocumentationNode>): String = StringBuilder().apply { 31 createOutputBuilder(this, location).appendNodes(nodes) 32 }.toString() 33