blob: 958e93aff912b02338e7679913088893b7c46a14 [file] [log] [blame]
Tiem Songe1dd5122019-07-03 14:16:39 -07001package org.jetbrains.dokka
2
3import java.io.File
4
5/**
6 * Service for building the outline of the package contents.
7 */
8interface OutlineFormatService {
9 fun getOutlineFileName(location: Location): File
10
11 fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder)
12 fun appendOutlineLevel(to: StringBuilder, body: () -> Unit)
13
14 /** Appends formatted outline to [StringBuilder](to) using specified [location] */
15 fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
16 for (node in nodes) {
17 appendOutlineHeader(location, node, to)
18 if (node.members.any()) {
19 val sortedMembers = node.members.sortedBy { it.name.toLowerCase() }
20 appendOutlineLevel(to) {
21 appendOutline(location, to, sortedMembers)
22 }
23 }
24 }
25 }
26
27 fun formatOutline(location: Location, nodes: Iterable<DocumentationNode>): String =
28 StringBuilder().apply { appendOutline(location, this, nodes) }.toString()
29}