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 | bfd9ffd | 2015-01-30 17:59:15 +0100 | [diff] [blame] | 84 | val described = nodes.filter { it.hasDescriptionOrTags() } |
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 |
Dmitry Jemerov | bfd9ffd | 2015-01-30 17:59:15 +0100 | [diff] [blame] | 87 | if (described.any { it.content.description != ContentEmpty }) { |
| 88 | appendHeader(to, "Description", 3) |
| 89 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 90 | for (node in described) { |
Ilya Ryzhenkov | fb41c69 | 2014-07-15 18:23:15 +0400 | [diff] [blame] | 91 | if (!single) { |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 92 | appendBlockCode(to, formatText(location, languageService.render(node))) |
Ilya Ryzhenkov | fb41c69 | 2014-07-15 18:23:15 +0400 | [diff] [blame] | 93 | } |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 94 | appendLine(to, formatText(location, node.content.description)) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 95 | appendLine(to) |
Dmitry Jemerov | bfd9ffd | 2015-01-30 17:59:15 +0100 | [diff] [blame] | 96 | |
| 97 | node.content.getSectionsWithSubjects().forEach { |
| 98 | appendSectionWithSubject(it.getKey(), location, it.getValue(), to) |
| 99 | } |
| 100 | |
Dmitry Jemerov | 0fac1d9 | 2015-01-30 19:01:40 +0100 | [diff] [blame] | 101 | for (section in node.content.sections.filter { it.subjectName == null }) { |
| 102 | appendLine(to, formatStrong(formatText(section.tag))) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 103 | appendLine(to, formatText(location, section)) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
Dmitry Jemerov | 0fac1d9 | 2015-01-30 19:01:40 +0100 | [diff] [blame] | 109 | fun Content.getSectionsWithSubjects(): Map<String, List<ContentSection>> = |
| 110 | sections.filter { it.subjectName != null }.groupBy { it.tag } |
| 111 | |
| 112 | fun appendSectionWithSubject(title: String, location: Location, subjectSections: List<ContentSection>, to: StringBuilder) { |
Dmitry Jemerov | bfd9ffd | 2015-01-30 17:59:15 +0100 | [diff] [blame] | 113 | appendHeader(to, title, 3) |
Dmitry Jemerov | 0fac1d9 | 2015-01-30 19:01:40 +0100 | [diff] [blame] | 114 | subjectSections.forEach { |
| 115 | val subjectName = it.subjectName |
| 116 | if (subjectName != null) { |
| 117 | to.append(formatCode(subjectName)).append(" - ") |
| 118 | to.append(formatText(location, it)) |
Dmitry Jemerov | bfd9ffd | 2015-01-30 17:59:15 +0100 | [diff] [blame] | 119 | appendLine(to) |
| 120 | } |
| 121 | } |
Dmitry Jemerov | c43a437 | 2014-12-29 20:22:43 +0100 | [diff] [blame] | 122 | } |
| 123 | |
Dmitry Jemerov | bfd9ffd | 2015-01-30 17:59:15 +0100 | [diff] [blame] | 124 | private fun DocumentationNode.hasDescriptionOrTags() = |
| 125 | content.description != ContentEmpty || !content.sections.isEmpty() |
| 126 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 127 | fun appendSummary(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 128 | val breakdownBySummary = nodes.groupByTo(LinkedHashMap()) { node -> |
Ilya Ryzhenkov | 280dc29 | 2014-10-14 16:08:10 +0400 | [diff] [blame] | 129 | formatText(location, node.summary) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | for ((summary, items) in breakdownBySummary) { |
Ilya Ryzhenkov | 7c6da4b | 2014-10-03 19:09:31 +0400 | [diff] [blame] | 133 | items.forEach { |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 134 | appendBlockCode(to, formatText(location, languageService.render(it))) |
Dmitry Jemerov | 0dd5ea3 | 2015-01-14 13:30:43 +0100 | [diff] [blame] | 135 | it.appendOverrides(to) |
| 136 | it.appendDeprecation(to) |
Dmitry Jemerov | 6146fa8 | 2015-01-14 18:46:36 +0100 | [diff] [blame] | 137 | it.appendSourceLink(to) |
Ilya Ryzhenkov | 7c6da4b | 2014-10-03 19:09:31 +0400 | [diff] [blame] | 138 | } |
Ilya Ryzhenkov | 280dc29 | 2014-10-14 16:08:10 +0400 | [diff] [blame] | 139 | appendLine(to, summary) |
Ilya Ryzhenkov | 455d74a | 2014-09-19 22:25:27 +0300 | [diff] [blame] | 140 | appendLine(to) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
Dmitry Jemerov | 0dd5ea3 | 2015-01-14 13:30:43 +0100 | [diff] [blame] | 144 | private fun DocumentationNode.appendOverrides(to: StringBuilder) { |
| 145 | overrides.forEach { |
| 146 | to.append("Overrides ") |
| 147 | val location = locationService.relativeLocation(this, it, extension) |
| 148 | appendLine(to, formatLink(FormatLink(it.owner!!.name + "." + it.name, location))) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | private fun DocumentationNode.appendDeprecation(to: StringBuilder) { |
| 153 | if (deprecation != null) { |
| 154 | val deprecationParameter = deprecation!!.details(DocumentationNode.Kind.Parameter).firstOrNull() |
| 155 | val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull() |
| 156 | if (deprecationValue != null) { |
| 157 | to.append(formatStrong("Deprecated: ")) |
| 158 | appendLine(to, formatText(deprecationValue.name.trim("\""))) |
| 159 | } else { |
| 160 | appendLine(to, formatStrong("Deprecated")) |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
Dmitry Jemerov | 6146fa8 | 2015-01-14 18:46:36 +0100 | [diff] [blame] | 165 | private fun DocumentationNode.appendSourceLink(to: StringBuilder) { |
| 166 | val sourceUrl = details(DocumentationNode.Kind.SourceUrl).firstOrNull() |
| 167 | if (sourceUrl != null) { |
| 168 | appendLine(to, formatLink("Source", sourceUrl.name)) |
| 169 | } |
| 170 | } |
| 171 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 172 | fun appendLocation(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
Ilya Ryzhenkov | bd494a8 | 2014-08-21 19:53:36 +0400 | [diff] [blame] | 173 | val breakdownByName = nodes.groupBy { node -> node.name } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 174 | for ((name, items) in breakdownByName) { |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 175 | appendHeader(to, formatText(name)) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 176 | appendSummary(location, to, items) |
| 177 | appendDescription(location, to, items) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 181 | 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] | 182 | if (nodes.any()) { |
| 183 | appendHeader(to, caption, 3) |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 184 | |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 185 | val children = nodes.sortBy { it.name } |
| 186 | val membersMap = children.groupBy { link(node, it) } |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 187 | |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 188 | appendTable(to) { |
| 189 | appendTableBody(to) { |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 190 | for ((memberLocation, members) in membersMap) { |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 191 | appendTableRow(to) { |
| 192 | appendTableCell(to) { |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 193 | to.append(formatLink(memberLocation)) |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 194 | } |
| 195 | appendTableCell(to) { |
Ilya Ryzhenkov | 280dc29 | 2014-10-14 16:08:10 +0400 | [diff] [blame] | 196 | val breakdownBySummary = members.groupBy { formatText(location, it.summary) } |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 197 | for ((summary, items) in breakdownBySummary) { |
Dmitry Jemerov | 3fc3e33 | 2014-12-30 15:35:00 +0100 | [diff] [blame] | 198 | val signatureTexts = items map { signature -> |
Dmitry Jemerov | 0c584d0 | 2015-01-12 17:23:07 +0100 | [diff] [blame] | 199 | val signature = languageService.render(signature, RenderMode.SUMMARY) |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 200 | val signatureAsCode = ContentCode() |
| 201 | signatureAsCode.append(signature) |
Dmitry Jemerov | 3fc3e33 | 2014-12-30 15:35:00 +0100 | [diff] [blame] | 202 | formatText(location, signatureAsCode) |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 203 | } |
Dmitry Jemerov | 3fc3e33 | 2014-12-30 15:35:00 +0100 | [diff] [blame] | 204 | signatureTexts.subList(0, signatureTexts.size()-1).forEach { |
| 205 | appendLine(to, it) |
| 206 | } |
| 207 | to.append(signatureTexts.last()) |
Ilya Ryzhenkov | a52e1d5 | 2014-10-03 15:57:16 +0400 | [diff] [blame] | 208 | if (!summary.isEmpty()) { |
Dmitry Jemerov | 8ef6818 | 2014-12-30 12:36:14 +0100 | [diff] [blame] | 209 | to.append(summary) |
Ilya Ryzhenkov | aa59acb | 2014-07-15 20:05:55 +0400 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | } |
Ilya Ryzhenkov | e8447fd | 2014-07-15 16:37:50 +0400 | [diff] [blame] | 213 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 214 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 215 | } |
| 216 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 220 | override fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { |
| 221 | val breakdownByLocation = nodes.groupBy { node -> |
| 222 | formatBreadcrumbs(node.path.map { link(node, it) }) |
| 223 | } |
| 224 | |
| 225 | for ((breadcrumbs, items) in breakdownByLocation) { |
| 226 | appendLine(to, breadcrumbs) |
| 227 | appendLine(to) |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 228 | appendLocation(location, to, items.filter { it.kind != DocumentationNode.Kind.ExternalClass }) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | for (node in nodes) { |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 232 | if (node.kind == DocumentationNode.Kind.ExternalClass) { |
| 233 | appendSection(location, "Extensions for ${node.name}", node.members, node, to) |
| 234 | continue |
| 235 | } |
| 236 | |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 237 | appendSection(location, "Packages", node.members(DocumentationNode.Kind.Package), node, to) |
| 238 | appendSection(location, "Types", node.members.filter { |
| 239 | it.kind in setOf( |
| 240 | DocumentationNode.Kind.Class, |
| 241 | DocumentationNode.Kind.Interface, |
| 242 | DocumentationNode.Kind.Enum, |
Dmitry Jemerov | 716483c | 2014-12-30 17:41:14 +0100 | [diff] [blame] | 243 | DocumentationNode.Kind.Object, |
| 244 | DocumentationNode.Kind.AnnotationClass) |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 245 | }, node, to) |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 246 | 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] | 247 | appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to) |
| 248 | appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to) |
| 249 | appendSection(location, "Functions", node.members(DocumentationNode.Kind.Function), node, to) |
Dmitry Jemerov | cedaeb4 | 2014-12-29 20:50:26 +0100 | [diff] [blame] | 250 | appendSection(location, "Class Object Properties", node.members(DocumentationNode.Kind.ClassObjectProperty), node, to) |
| 251 | appendSection(location, "Class Object Functions", node.members(DocumentationNode.Kind.ClassObjectFunction), node, to) |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 252 | appendSection(location, "Accessors", node.members(DocumentationNode.Kind.PropertyAccessor), node, to) |
Dmitry Jemerov | c4f40a0 | 2015-01-12 16:32:30 +0100 | [diff] [blame] | 253 | appendSection(location, "Enum Values", node.members(DocumentationNode.Kind.EnumItem), node, to) |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 254 | appendSection(location, "Other members", node.members.filter { |
| 255 | it.kind !in setOf( |
| 256 | DocumentationNode.Kind.Class, |
| 257 | DocumentationNode.Kind.Interface, |
Dmitry Jemerov | 716483c | 2014-12-30 17:41:14 +0100 | [diff] [blame] | 258 | DocumentationNode.Kind.Enum, |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 259 | DocumentationNode.Kind.Object, |
Dmitry Jemerov | 716483c | 2014-12-30 17:41:14 +0100 | [diff] [blame] | 260 | DocumentationNode.Kind.AnnotationClass, |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 261 | DocumentationNode.Kind.Constructor, |
| 262 | DocumentationNode.Kind.Property, |
| 263 | DocumentationNode.Kind.Package, |
| 264 | DocumentationNode.Kind.Function, |
Dmitry Jemerov | cedaeb4 | 2014-12-29 20:50:26 +0100 | [diff] [blame] | 265 | DocumentationNode.Kind.PropertyAccessor, |
| 266 | DocumentationNode.Kind.ClassObjectProperty, |
Dmitry Jemerov | 4b0dcee | 2015-01-09 19:48:44 +0100 | [diff] [blame] | 267 | DocumentationNode.Kind.ClassObjectFunction, |
Dmitry Jemerov | c4f40a0 | 2015-01-12 16:32:30 +0100 | [diff] [blame] | 268 | DocumentationNode.Kind.ExternalClass, |
| 269 | DocumentationNode.Kind.EnumItem |
Ilya Ryzhenkov | 4907736 | 2014-10-14 19:53:13 +0400 | [diff] [blame] | 270 | ) |
| 271 | }, node, to) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 272 | appendSection(location, "Extensions", node.extensions, node, to) |
Dmitry Jemerov | c4f40a0 | 2015-01-12 16:32:30 +0100 | [diff] [blame] | 273 | appendSection(location, "Inheritors", |
| 274 | node.inheritors.filter { it.kind != DocumentationNode.Kind.EnumItem }, node, to) |
Ilya Ryzhenkov | d6fd045 | 2014-10-03 20:20:02 +0400 | [diff] [blame] | 275 | appendSection(location, "Links", node.links, node, to) |
| 276 | |
| 277 | } |
| 278 | } |
Ilya Ryzhenkov | 62cb509 | 2014-07-15 15:54:05 +0400 | [diff] [blame] | 279 | } |