blob: 6d2c0a3dd012b7405be2b20fc7d9c24b1778bf37 (
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
|
package org.jetbrains.dokka
import java.io.FileOutputStream
import java.io.OutputStreamWriter
import java.util.LinkedHashMap
public class FileGenerator(val signatureGenerator: SignatureGenerator,
val locationService: LocationService,
val formatService: FormatService) {
public fun generate(node: DocumentationNode): Unit = generate(listOf(node))
public fun generate(nodes: Iterable<DocumentationNode>) {
for ((location, items) in nodes.groupByTo(LinkedHashMap()) { locationService.location(it) }) {
val file = location.file.appendExtension(formatService.extension)
file.getParentFile()?.mkdirs()
FileOutputStream(file).use {
OutputStreamWriter(it, defaultCharset).use {
it.write(formatService.format(items))
}
}
generate(items.flatMap { it.members })
}
}
}
|