aboutsummaryrefslogtreecommitdiff
path: root/src/Generation/ConsoleGenerator.kt
blob: e46cac3133bd36bdc98a4aae9d6f49ecd9f25b36 (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
27
package org.jetbrains.dokka

public class ConsoleGenerator() {
    val IndentStep = "  "

    public fun generate(node: DocumentationNode, indent: String = "") {
        generateHeader(node, indent)
        generateDetails(node, indent)
        generateMembers(node, indent)
    }

    public fun generateHeader(node: DocumentationNode, indent: String = "") {
        println("$indent${node.kind}: ${node.name}")
        println("$indent\"${node.doc.replace("\n", "\n$indent")}\"")
        println()
    }

    public fun generateDetails(node: DocumentationNode, indent: String = "") {
        for (child in node.details)
            generate(child, indent + IndentStep)
    }

    public fun generateMembers(node: DocumentationNode, indent: String = "") {
        for (child in node.members)
            generate(child, indent + IndentStep)
    }
}