package org.jetbrains.dokka public class KotlinWebsiteFormatService(locationService: LocationService, signatureGenerator: LanguageService) : JekyllFormatService(locationService, signatureGenerator) { private var needHardLineBreaks = false override fun appendFrontMatter(nodes: Iterable, to: StringBuilder) { super.appendFrontMatter(nodes, to) to.appendln("layout: api") } override public fun formatBreadcrumbs(items: Iterable): String { items.drop(1) if (items.count() > 1) { return "
" + items.map { formatLink(it) }.joinToString(" / ") + "
" } return "" } override public fun formatCode(code: String): String = if (code.length > 0) "$code" else "" override fun formatStrikethrough(text: String): String = "$text" override fun appendAsSignature(to: StringBuilder, node: ContentNode, block: () -> Unit) { val contentLength = node.textLength if (contentLength == 0) return to.append("
") needHardLineBreaks = contentLength >= 62 try { block() } finally { needHardLineBreaks = false } to.append("
") } override fun formatLink(text: String, href: String): String { return "${text}" } override fun appendTable(to: StringBuilder, body: () -> Unit) { to.appendln("") body() to.appendln("
") } override fun appendTableHeader(to: StringBuilder, body: () -> Unit) { to.appendln("") body() to.appendln("") } override fun appendTableBody(to: StringBuilder, body: () -> Unit) { to.appendln("") body() to.appendln("") } override fun appendTableRow(to: StringBuilder, body: () -> Unit) { to.appendln("") body() to.appendln("") } override fun appendTableCell(to: StringBuilder, body: () -> Unit) { to.appendln("") body() to.appendln("\n") } override public fun appendBlockCode(to: StringBuilder, line: String, language: String) { if (language.isNotEmpty()) { super.appendBlockCode(to, line, language) } else { to.append("
")
            to.append(line.trimStart())
            to.append("
") } } override fun formatSymbol(text: String): String { return "${formatText(text)}" } override fun formatKeyword(text: String): String { return "${formatText(text)}" } override fun formatIdentifier(text: String, kind: IdentifierKind): String { return "${formatText(text)}" } override fun formatSoftLineBreak(): String = if (needHardLineBreaks) "
" else "" override fun formatIndentedSoftLineBreak(): String = if (needHardLineBreaks) "
    " else "" private fun identifierClassName(kind: IdentifierKind) = when(kind) { IdentifierKind.ParameterName -> "parameterName" IdentifierKind.SummarizedTypeName -> "summarizedTypeName" else -> "identifier" } }