package org.jetbrains.dokka import com.google.inject.Inject public class KotlinWebsiteFormatService @Inject constructor(locationService: LocationService, signatureGenerator: LanguageService) : JekyllFormatService(locationService, signatureGenerator, "html") { 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 appendAsOverloadGroup(to: StringBuilder, block: () -> Unit) { to.append("
\n") block() to.append("
\n") } 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" } }