diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-01-30 17:59:15 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-01-30 17:59:15 +0100 |
commit | bfd9ffd13ed6b6916790f5f0de5f9523db71b22e (patch) | |
tree | 214ae0ff76e8b35841947b639ce3c2022ad72fec /src/Formats/StructuredFormatService.kt | |
parent | b55b258574a01a02f906f5f12646ecacfc640e20 (diff) | |
download | dokka-bfd9ffd13ed6b6916790f5f0de5f9523db71b22e.tar.gz dokka-bfd9ffd13ed6b6916790f5f0de5f9523db71b22e.tar.bz2 dokka-bfd9ffd13ed6b6916790f5f0de5f9523db71b22e.zip |
load sections from KDoc PSI, not through Markdown extensions
Diffstat (limited to 'src/Formats/StructuredFormatService.kt')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index d2fbdc10..fe127732 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -81,36 +81,48 @@ public abstract class StructuredFormatService(val locationService: LocationServi } fun appendDescription(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { - val described = nodes.filter { it.hasDescription() } + val described = nodes.filter { it.hasDescriptionOrTags() } if (described.any()) { val single = described.size() == 1 - appendHeader(to, "Description", 3) + if (described.any { it.content.description != ContentEmpty }) { + appendHeader(to, "Description", 3) + } for (node in described) { if (!single) { appendBlockCode(to, formatText(location, languageService.render(node))) } appendLine(to, formatText(location, node.content.description)) appendLine(to) - for ((label, section) in node.content.sections) { - if (!isDescriptionSection(label, node)) continue - appendLine(to, formatStrong(formatText(label))) + + node.content.getSectionsWithSubjects().forEach { + appendSectionWithSubject(it.getKey(), location, it.getValue(), to) + } + + for (section in node.content.sections) { + if (section.subjectName != null) continue + appendLine(to, formatStrong(formatText(section.label))) appendLine(to, formatText(location, section)) } } } } - private fun DocumentationNode.hasDescription() = - content.description != ContentEmpty || content.sections.any { isDescriptionSection(it.key, this) } - - private fun isDescriptionSection(label: String, node: DocumentationNode): Boolean { - if (label.startsWith("$")) - return false - if (node.members.any { it.name == label }) - return false - return true + fun appendSectionWithSubject(title: String, location: Location, parameterSections: List<ContentSection>, to: StringBuilder) { + appendHeader(to, title, 3) + parameterSections.forEach { + val parameterName = it.subjectName + if (parameterName != null) { + to.append(formatCode(parameterName)).append(" - ") + val formatted = formatText(location, it) + to.append(formatted) + appendLine(to) + } + } } + private fun DocumentationNode.hasDescriptionOrTags() = + content.description != ContentEmpty || !content.sections.isEmpty() + fun appendSummary(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { val breakdownBySummary = nodes.groupByTo(LinkedHashMap()) { node -> formatText(location, node.summary) |