From 82de2309e53df4206e99beb36ef51326dbae48a2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Jan 2015 16:55:22 +0100 Subject: refactor outline generation; generate HTML outline --- src/Formats/OutlineService.kt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Formats/OutlineService.kt (limited to 'src/Formats/OutlineService.kt') diff --git a/src/Formats/OutlineService.kt b/src/Formats/OutlineService.kt new file mode 100644 index 00000000..db1adf3d --- /dev/null +++ b/src/Formats/OutlineService.kt @@ -0,0 +1,30 @@ +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) { + 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) + } + } + to.appendln() + } + } + + fun formatOutline(location: Location, nodes: Iterable): String = + StringBuilder { appendOutline(location, this, nodes) }.toString() +} -- cgit From 29d0822f4521ac1a9d17f78be6e41488b2ef00d2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Jan 2015 18:50:53 +0100 Subject: remove unnecessary println() --- src/Formats/OutlineService.kt | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Formats/OutlineService.kt') diff --git a/src/Formats/OutlineService.kt b/src/Formats/OutlineService.kt index db1adf3d..9f25da50 100644 --- a/src/Formats/OutlineService.kt +++ b/src/Formats/OutlineService.kt @@ -21,7 +21,6 @@ public trait OutlineFormatService { appendOutline(location, to, sortedMembers) } } - to.appendln() } } -- cgit