aboutsummaryrefslogtreecommitdiff
path: root/src/Formats/OutlineService.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <intelliyole@gmail.com>2015-01-16 19:14:24 +0100
committerDmitry Jemerov <intelliyole@gmail.com>2015-01-16 19:14:24 +0100
commit5eab453ea82634af9b876bff26227ec2d0e753ca (patch)
treefed6a72ab7d4998b3acfffc2eafc0d01d2ee0ef0 /src/Formats/OutlineService.kt
parentd75cc63e9b1edc229fad225956ba44fa433e2d0e (diff)
parent29d0822f4521ac1a9d17f78be6e41488b2ef00d2 (diff)
downloaddokka-5eab453ea82634af9b876bff26227ec2d0e753ca.tar.gz
dokka-5eab453ea82634af9b876bff26227ec2d0e753ca.tar.bz2
dokka-5eab453ea82634af9b876bff26227ec2d0e753ca.zip
Merge pull request #23 from orangy/html-outline
refactor outline generation; generate HTML outline
Diffstat (limited to 'src/Formats/OutlineService.kt')
-rw-r--r--src/Formats/OutlineService.kt29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Formats/OutlineService.kt b/src/Formats/OutlineService.kt
new file mode 100644
index 00000000..9f25da50
--- /dev/null
+++ b/src/Formats/OutlineService.kt
@@ -0,0 +1,29 @@
+package org.jetbrains.dokka
+
+import java.io.File
+
+/**
+ * Service for building the outline of the package contents.
+ */
+public trait OutlineFormatService {
+ fun getOutlineFileName(location: Location): File
+
+ public fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder)
+ public fun appendOutlineLevel(to: StringBuilder, body: () -> Unit)
+
+ /** Appends formatted outline to [StringBuilder](to) using specified [location] */
+ public fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
+ for (node in nodes) {
+ appendOutlineHeader(location, node, to)
+ if (node.members.any()) {
+ val sortedMembers = node.members.sortBy { it.name }
+ appendOutlineLevel(to) {
+ appendOutline(location, to, sortedMembers)
+ }
+ }
+ }
+ }
+
+ fun formatOutline(location: Location, nodes: Iterable<DocumentationNode>): String =
+ StringBuilder { appendOutline(location, this, nodes) }.toString()
+}