aboutsummaryrefslogtreecommitdiff
path: root/src/Generation/FileGenerator.kt
blob: c1e88a76363bc0be8fb81cbe7635197ea825315e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package org.jetbrains.dokka

import java.io.File

public class FileGenerator(val signatureGenerator: SignatureGenerator,
                           val locationService: LocationService,
                           val formatService: FormatService) {
    public fun generate(node: DocumentationNode) {
        val location = locationService.location(node)
        println("@${location.file} : ${signatureGenerator.render(node)}")
        val file = location.file.appendExtension(formatService.extension)
        file.getParentFile()?.mkdirs()
        file.writeText(formatService.format(node), defaultCharset)
        val items = node.members.sortBy { it.name }
        for (child in items)
            generate(child)
    }
}