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