diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-14 21:15:27 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-14 21:15:27 +0400 |
commit | 3eee7f212798e65ff627d31e394a3658b658bc46 (patch) | |
tree | b1f91146d5df0757bdd916cb848ae3b8c8548220 /src/Generation/FileGenerator.kt | |
parent | cd7084ddc4e6e7f32a35d265bfb1307fdaf27011 (diff) | |
download | dokka-3eee7f212798e65ff627d31e394a3658b658bc46.tar.gz dokka-3eee7f212798e65ff627d31e394a3658b658bc46.tar.bz2 dokka-3eee7f212798e65ff627d31e394a3658b658bc46.zip |
Refactor to multiple-nodes formatting, join content.
Diffstat (limited to 'src/Generation/FileGenerator.kt')
-rw-r--r-- | src/Generation/FileGenerator.kt | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/Generation/FileGenerator.kt b/src/Generation/FileGenerator.kt index 105c14e6..6d2c0a3d 100644 --- a/src/Generation/FileGenerator.kt +++ b/src/Generation/FileGenerator.kt @@ -1,18 +1,25 @@ package org.jetbrains.dokka -import java.io.File +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) { - val location = locationService.location(node) - val file = location.file.appendExtension(formatService.extension) - file.getParentFile()?.mkdirs() - file.writeText(formatService.format(node), defaultCharset) - val members = node.members.sortBy { it.name } - for (member in members) - generate(member) + 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 }) + } } }
\ No newline at end of file |