aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Formats/YamlOutlineService.kt
blob: 39a5b9b3a604366e5c9b85fc66b7071d15045d98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package org.jetbrains.dokka

import com.google.inject.Inject
import java.io.File

class YamlOutlineService @Inject constructor(val locationService: LocationService,
                         val languageService: LanguageService) : OutlineFormatService {
    override fun getOutlineFile(location: Location): File = File("${location.path}.yml")

    var outlineLevel = 0
    override fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder) {
        val indent = "    ".repeat(outlineLevel)
        to.appendln("$indent- title: ${languageService.renderName(node)}")
        to.appendln("$indent  url: ${locationService.location(node).path}")
    }

    override fun appendOutlineLevel(to: StringBuilder, body: () -> Unit) {
        val indent = "    ".repeat(outlineLevel)
        to.appendln("$indent  content:")
        outlineLevel++
        body()
        outlineLevel--
    }

    override fun getOutlineFileName(): String = "index"
}