package org.jetbrains.dokka.renderers import org.jetbrains.dokka.utilities.htmlEscape import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.resolvers.LocationProvider import java.io.File import java.net.URL open class HtmlRenderer( fileWriter: FileWriter, locationProvider: LocationProvider, context: DokkaContext ) : DefaultRenderer(fileWriter, locationProvider, context) { override fun buildList(node: ContentList, pageContext: PageNode): String = if (node.ordered) { "
${node.children.joinToString(" | \n
\n") { it.buildTableRow(pageContext) }} | |
${code.joinToString("") { (it as ContentText).text + buildNewLine() }}
"
override fun buildText(textNode: ContentText): String = super.buildText(textNode).htmlEscape()
override fun renderPage(page: PageNode) {
val pageText = buildStartHtml(page) + buildPageContent(page) + buildEndHtml()
fileWriter.write(locationProvider.resolve(page), pageText, "")
}
override fun buildSupportFiles() { // TODO copy file instead of reading
fileWriter.write(
"style.css",
javaClass.getResourceAsStream("/dokka/styles/style.css").reader().readText()
)
}
protected open fun buildScripts(page: PageNode) =
page.embeddedResources.filter { URL(it).path.substringAfterLast('.') == "js" }
.joinToString(separator = "") { """""" + "\n" }
protected open fun buildStartHtml(page: PageNode) = """
|
|
|