Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 1 | package org.jetbrains.dokka |
| 2 | |
| 3 | import java.util.LinkedHashMap |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 4 | |
| 5 | public data class FormatLink(val text: String, val location: Location) |
| 6 | |
| 7 | public abstract class StructuredFormatService(val locationService: LocationService, |
Ilya Ryzhenkov | 499d082 | 2014-07-15 16:18:53 +0400 | [diff] [blame] | 8 | val languageService: LanguageService) : FormatService { |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 9 | |
| 10 | abstract public fun appendBlockCode(to: StringBuilder, line: String) |
| 11 | abstract public fun appendBlockCode(to: StringBuilder, lines: Iterable<String>) |
| 12 | abstract public fun appendHeader(to: StringBuilder, text: String, level: Int = 1) |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 13 | abstract public fun appendParagraph(to: StringBuilder, text: String) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 14 | abstract public fun appendLine(to: StringBuilder, text: String) |
| 15 | public abstract fun appendLine(to: StringBuilder) |
Ilya Ryzhenkov | 499d082 | 2014-07-15 16:18:53 +0400 | [diff] [blame] | 16 | |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 17 | public abstract fun appendTable(to: StringBuilder, body: () -> Unit) |
| 18 | public abstract fun appendTableHeader(to: StringBuilder, body: () -> Unit) |
| 19 | public abstract fun appendTableBody(to: StringBuilder, body: () -> Unit) |
| 20 | public abstract fun appendTableRow(to: StringBuilder, body: () -> Unit) |
| 21 | public abstract fun appendTableCell(to: StringBuilder, body: () -> Unit) |
Ilya Ryzhenkov | 499d082 | 2014-07-15 16:18:53 +0400 | [diff] [blame] | 22 | |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 23 | public abstract fun formatText(text: String): String |
Ilya Ryzhenkov | 7c6da4b | 2014-10-03 19:09:31 +0400 | [diff] [blame] | 24 | public abstract fun formatSymbol(text: String): String |
| 25 | public abstract fun formatKeyword(text: String): String |
| 26 | public abstract fun formatIdentifier(text: String): String |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 27 | public abstract fun formatLink(text: String, location: Location): String |
Ilya Ryzhenkov | 71cd87e | 2014-10-03 22:51:44 +0400 | [diff] [blame] | 28 | public abstract fun formatLink(text: String, href: String): String |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 29 | public open fun formatLink(link: FormatLink): String = formatLink(formatText(link.text), link.location) |
Ilya Ryzhenkov | 9f0ff55 | 2014-10-13 13:38:40 +0400 | [diff] [blame] | 30 | public abstract fun formatStrong(text: String): String |
Dmitry Jemerov | e17eaa5 | 2015-01-09 20:59:58 +0100 | [diff] [blame] | 31 | public abstract fun formatStrikethrough(text: String): String |
Ilya Ryzhenkov | 9f0ff55 | 2014-10-13 13:38:40 +0400 | [diff] [blame] | 32 | public abstract fun formatEmphasis(text: String): String |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 33 | public abstract fun formatCode(code: String): String |
Ilya Ryzhenkov | 1839949 | 2014-12-22 09:50:17 +0200 | [diff] [blame] | 34 | public abstract fun formatList(text: String): String |
| 35 | public abstract fun formatListItem(text: String): String |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 36 | public abstract fun formatBreadcrumbs(items: Iterable<FormatLink>): String |
| 37 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 38 | open fun formatText(location: Location, nodes: Iterable<ContentNode>): String { |
| 39 | return nodes.map { formatText(location, it) }.join("") |
Ilya Ryzhenkov | 778e2b3 | 2014-09-29 20:54:59 +0400 | [diff] [blame] | 40 | } |
| 41 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 42 | open fun formatText(location: Location, content: ContentNode): String { |
Ilya Ryzhenkov | 455d74a | 2014-09-19 22:25:27 +0300 | [diff] [blame] | 43 | return StringBuilder { |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 44 | when (content) { |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 45 | is ContentText -> append(formatText(content.text)) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 46 | is ContentSymbol -> append(formatSymbol(content.text)) |
| 47 | is ContentKeyword -> append(formatKeyword(content.text)) |
| 48 | is ContentIdentifier -> append(formatIdentifier(content.text)) |
Ilya Ryzhenkov | 9f0ff55 | 2014-10-13 13:38:40 +0400 | [diff] [blame] | 49 | is ContentStrong -> append(formatStrong(formatText(location, content.children))) |
Dmitry Jemerov | e17eaa5 | 2015-01-09 20:59:58 +0100 | [diff] [blame] | 50 | is ContentStrikethrough -> append(formatStrikethrough(formatText(location, content.children))) |
Ilya Ryzhenkov | 9f0ff55 | 2014-10-13 13:38:40 +0400 | [diff] [blame] | 51 | is ContentCode -> append(formatCode(formatText(location, content.children))) |
| 52 | is ContentEmphasis -> append(formatEmphasis(formatText(location, content.children))) |
Ilya Ryzhenkov | 1839949 | 2014-12-22 09:50:17 +0200 | [diff] [blame] | 53 | is ContentList -> append(formatList(formatText(location, content.children))) |
| 54 | is ContentListItem -> append(formatListItem(formatText(location, content.children))) |
| 55 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 56 | is ContentNodeLink -> { |
| 57 | val linkTo = locationService.relativeLocation(location, content.node, extension) |
| 58 | val linkText = formatText(location, content.children) |
| 59 | append(formatLink(linkText, linkTo)) |
| 60 | } |
Ilya Ryzhenkov | 71cd87e | 2014-10-03 22:51:44 +0400 | [diff] [blame] | 61 | is ContentExternalLink -> { |
| 62 | val linkText = formatText(location, content.children) |
| 63 | append(formatLink(linkText, content.href)) |
| 64 | } |
Ilya Ryzhenkov | ad14ea9 | 2014-10-13 18:22:02 +0400 | [diff] [blame] | 65 | is ContentParagraph -> { |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 66 | appendParagraph(this, formatText(location, content.children)) |
Ilya Ryzhenkov | ad14ea9 | 2014-10-13 18:22:02 +0400 | [diff] [blame] | 67 | } |
Ilya Ryzhenkov | 1cb3af9 | 2014-10-13 20:14:45 +0400 | [diff] [blame] | 68 | is ContentBlockCode -> { |
| 69 | appendBlockCode(this, formatText(location, content.children)) |
| 70 | } |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 71 | else -> append(formatText(location, content.children)) |
Ilya Ryzhenkov | 455d74a | 2014-09-19 22:25:27 +0300 | [diff] [blame] | 72 | } |
| 73 | }.toString() |
| 74 | } |
| 75 | |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 76 | open public fun link(from: DocumentationNode, to: DocumentationNode): FormatLink = link(from, to, extension) |
| 77 | |
| 78 | open public fun link(from: DocumentationNode, to: DocumentationNode, extension: String): FormatLink { |
| 79 | return FormatLink(to.name, locationService.relativeLocation(from, to, extension)) |
| 80 | } |
| 81 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 82 | fun appendDescription(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
Dmitry Jemerov | c43a437 | 2014-12-29 20:22:43 +0100 | [diff] [blame] | 83 | val described = nodes.filter { it.hasDescription() } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 84 | if (described.any()) { |
Dmitry Jemerov | c43a437 | 2014-12-29 20:22:43 +0100 | [diff] [blame] | 85 | val single = described.size() == 1 |
Ilya Ryzhenkov | fb41c69 | 2014-07-15 18:23:15 +0400 | [diff] [blame] | 86 | appendHeader(to, "Description", 3) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 87 | for (node in described) { |
Ilya Ryzhenkov | fb41c69 | 2014-07-15 18:23:15 +0400 | [diff] [blame] | 88 | if (!single) { |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 89 | appendBlockCode(to, formatText(location, languageService.render(node))) |
Ilya Ryzhenkov | fb41c69 | 2014-07-15 18:23:15 +0400 | [diff] [blame] | 90 | } |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 91 | appendLine(to, formatText(location, node.content.description)) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 92 | appendLine(to) |
Ilya Ryzhenkov | 280dc29 | 2014-10-14 16:08:10 +0400 | [diff] [blame] | 93 | for ((label, section) in node.content.sections) { |
Dmitry Jemerov | c43a437 | 2014-12-29 20:22:43 +0100 | [diff] [blame] | 94 | if (!isDescriptionSection(label, node)) continue |
Ilya Ryzhenkov | 9f0ff55 | 2014-10-13 13:38:40 +0400 | [diff] [blame] | 95 | appendLine(to, formatStrong(formatText(label))) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 96 | appendLine(to, formatText(location, section)) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 97 | } |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
Dmitry Jemerov | c43a437 | 2014-12-29 20:22:43 +0100 | [diff] [blame] | 102 | private fun DocumentationNode.hasDescription() = |
| 103 | content.description != ContentEmpty || content.sections.any { isDescriptionSection(it.key, this) } |
| 104 | |
| 105 | private fun isDescriptionSection(label: String, node: DocumentationNode): Boolean { |
| 106 | if (label.startsWith("$")) |
| 107 | return false |
| 108 | if (node.members.any { it.name == label }) |
| 109 | return false |
| 110 | return true |
| 111 | } |
| 112 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 113 | fun appendSummary(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 114 | val breakdownBySummary = nodes.groupByTo(LinkedHashMap()) { node -> |
Ilya Ryzhenkov | 280dc29 | 2014-10-14 16:08:10 +0400 | [diff] [blame] | 115 | formatText(location, node.summary) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | for ((summary, items) in breakdownBySummary) { |
Ilya Ryzhenkov | 7c6da4b | 2014-10-03 19:09:31 +0400 | [diff] [blame] | 119 | items.forEach { |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 120 | appendBlockCode(to, formatText(location, languageService.render(it))) |
Dmitry Jemerov | e17eaa5 | 2015-01-09 20:59:58 +0100 | [diff] [blame] | 121 | val deprecation = it.deprecation |
| 122 | if (deprecation != null) { |
| 123 | val deprecationParameter = deprecation.details(DocumentationNode.Kind.Parameter).firstOrNull() |
| 124 | val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull() |
| 125 | if (deprecationValue != null) { |
| 126 | to.append(formatStrong("Deprecated: ")) |
Dmitry Jemerov | 23af5e2 | 2015-01-12 15:57:04 +0100 | [diff] [blame] | 127 | appendLine(to, formatText(deprecationValue.name.trim("\""))) |
Dmitry Jemerov | e17eaa5 | 2015-01-09 20:59:58 +0100 | [diff] [blame] | 128 | } else { |
| 129 | appendLine(to, formatStrong("Deprecated")) |
| 130 | } |
| 131 | } |
Ilya Ryzhenkov | 7c6da4b | 2014-10-03 19:09:31 +0400 | [diff] [blame] | 132 | } |
Ilya Ryzhenkov | 280dc29 | 2014-10-14 16:08:10 +0400 | [diff] [blame] | 133 | appendLine(to, summary) |
Ilya Ryzhenkov | 455d74a | 2014-09-19 22:25:27 +0300 | [diff] [blame] | 134 | appendLine(to) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 138 | fun appendLocation(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
Ilya Ryzhenkov | bd494a8 | 2014-08-21 19:53:36 +0400 | [diff] [blame] | 139 | val breakdownByName = nodes.groupBy { node -> node.name } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 140 | for ((name, items) in breakdownByName) { |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 141 | appendHeader(to, formatText(name)) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 142 | appendSummary(location, to, items) |
| 143 | appendDescription(location, to, items) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 147 | private fun StructuredFormatService.appendSection(location: Location, caption: String, nodes: List<DocumentationNode>, node: DocumentationNode, to: StringBuilder) { |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 148 | if (nodes.any()) { |
| 149 | appendHeader(to, caption, 3) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 150 | |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 151 | val children = nodes.sortBy { it.name } |
| 152 | val membersMap = children.groupBy { link(node, it) } |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 153 | |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 154 | appendTable(to) { |
| 155 | appendTableBody(to) { |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 156 | for ((memberLocation, members) in membersMap) { |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 157 | appendTableRow(to) { |
| 158 | appendTableCell(to) { |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 159 | to.append(formatLink(memberLocation)) |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 160 | } |
| 161 | appendTableCell(to) { |
Ilya Ryzhenkov | 280dc29 | 2014-10-14 16:08:10 +0400 | [diff] [blame] | 162 | val breakdownBySummary = members.groupBy { formatText(location, it.summary) } |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 163 | for ((summary, items) in breakdownBySummary) { |
Dmitry Jemerov | 3fc3e33 | 2014-12-30 15:35:00 +0100 | [diff] [blame] | 164 | val signatureTexts = items map { signature -> |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 165 | val signature = languageService.render(signature) |
| 166 | val signatureAsCode = ContentCode() |
| 167 | signatureAsCode.append(signature) |
Dmitry Jemerov | 3fc3e33 | 2014-12-30 15:35:00 +0100 | [diff] [blame] | 168 | formatText(location, signatureAsCode) |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 169 | } |
Dmitry Jemerov | 3fc3e33 | 2014-12-30 15:35:00 +0100 | [diff] [blame] | 170 | signatureTexts.subList(0, signatureTexts.size()-1).forEach { |
| 171 | appendLine(to, it) |
| 172 | } |
| 173 | to.append(signatureTexts.last()) |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 174 | if (!summary.isEmpty()) { |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 175 | to.append(summary) |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 176 | } |
| 177 | } |
| 178 | } |
Ilya Ryzhenkov | e8447fd | 2014-07-15 16:37:50 +0400 | [diff] [blame] | 179 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 180 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 181 | } |
| 182 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 186 | override fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
| 187 | val breakdownByLocation = nodes.groupBy { node -> |
| 188 | formatBreadcrumbs(node.path.map { link(node, it) }) |
| 189 | } |
| 190 | |
| 191 | for ((breadcrumbs, items) in breakdownByLocation) { |
| 192 | appendLine(to, breadcrumbs) |
| 193 | appendLine(to) |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 194 | appendLocation(location, to, items.filter { it.kind != DocumentationNode.Kind.ExternalClass }) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | for (node in nodes) { |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 198 | if (node.kind == DocumentationNode.Kind.ExternalClass) { |
| 199 | appendSection(location, "Extensions for ${node.name}", node.members, node, to) |
| 200 | continue |
| 201 | } |
| 202 | |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 203 | appendSection(location, "Packages", node.members(DocumentationNode.Kind.Package), node, to) |
| 204 | appendSection(location, "Types", node.members.filter { |
| 205 | it.kind in setOf( |
| 206 | DocumentationNode.Kind.Class, |
| 207 | DocumentationNode.Kind.Interface, |
| 208 | DocumentationNode.Kind.Enum, |
Dmitry Jemerov | 716483c | 2014-12-30 17:41:14 +0100 | [diff] [blame] | 209 | DocumentationNode.Kind.Object, |
| 210 | DocumentationNode.Kind.AnnotationClass) |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 211 | }, node, to) |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 212 | appendSection(location, "Extensions for External Classes", node.members(DocumentationNode.Kind.ExternalClass), node, to) |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 213 | appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to) |
| 214 | appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to) |
| 215 | appendSection(location, "Functions", node.members(DocumentationNode.Kind.Function), node, to) |
Dmitry Jemerov | cedaeb4 | 2014-12-29 20:50:26 +0100 | [diff] [blame] | 216 | appendSection(location, "Class Object Properties", node.members(DocumentationNode.Kind.ClassObjectProperty), node, to) |
| 217 | appendSection(location, "Class Object Functions", node.members(DocumentationNode.Kind.ClassObjectFunction), node, to) |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 218 | appendSection(location, "Accessors", node.members(DocumentationNode.Kind.PropertyAccessor), node, to) |
Dmitry Jemerov | c4f40a0 | 2015-01-12 16:32:30 +0100 | [diff] [blame^] | 219 | appendSection(location, "Enum Values", node.members(DocumentationNode.Kind.EnumItem), node, to) |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 220 | appendSection(location, "Other members", node.members.filter { |
| 221 | it.kind !in setOf( |
| 222 | DocumentationNode.Kind.Class, |
| 223 | DocumentationNode.Kind.Interface, |
Dmitry Jemerov | 716483c | 2014-12-30 17:41:14 +0100 | [diff] [blame] | 224 | DocumentationNode.Kind.Enum, |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 225 | DocumentationNode.Kind.Object, |
Dmitry Jemerov | 716483c | 2014-12-30 17:41:14 +0100 | [diff] [blame] | 226 | DocumentationNode.Kind.AnnotationClass, |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 227 | DocumentationNode.Kind.Constructor, |
| 228 | DocumentationNode.Kind.Property, |
| 229 | DocumentationNode.Kind.Package, |
| 230 | DocumentationNode.Kind.Function, |
Dmitry Jemerov | cedaeb4 | 2014-12-29 20:50:26 +0100 | [diff] [blame] | 231 | DocumentationNode.Kind.PropertyAccessor, |
| 232 | DocumentationNode.Kind.ClassObjectProperty, |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 233 | DocumentationNode.Kind.ClassObjectFunction, |
Dmitry Jemerov | c4f40a0 | 2015-01-12 16:32:30 +0100 | [diff] [blame^] | 234 | DocumentationNode.Kind.ExternalClass, |
| 235 | DocumentationNode.Kind.EnumItem |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 236 | ) |
| 237 | }, node, to) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 238 | appendSection(location, "Extensions", node.extensions, node, to) |
Dmitry Jemerov | c4f40a0 | 2015-01-12 16:32:30 +0100 | [diff] [blame^] | 239 | appendSection(location, "Inheritors", |
| 240 | node.inheritors.filter { it.kind != DocumentationNode.Kind.EnumItem }, node, to) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 241 | appendSection(location, "Links", node.links, node, to) |
| 242 | |
| 243 | } |
| 244 | } |
| 245 | |
Ilya Ryzhenkov | 499d082 | 2014-07-15 16:18:53 +0400 | [diff] [blame] | 246 | abstract public fun appendOutlineHeader(to: StringBuilder, node: DocumentationNode) |
| 247 | abstract public fun appendOutlineChildren(to: StringBuilder, nodes: Iterable<DocumentationNode>) |
| 248 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 249 | public override fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
Ilya Ryzhenkov | 499d082 | 2014-07-15 16:18:53 +0400 | [diff] [blame] | 250 | for (node in nodes) { |
| 251 | appendOutlineHeader(to, node) |
| 252 | if (node.members.any()) { |
| 253 | appendOutlineChildren(to, node.members) |
| 254 | } |
| 255 | } |
| 256 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 257 | } |