aboutsummaryrefslogtreecommitdiff
path: root/src/Formats/StructuredFormatService.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Formats/StructuredFormatService.kt')
-rw-r--r--src/Formats/StructuredFormatService.kt40
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)