diff options
Diffstat (limited to 'src/Formats/StructuredFormatService.kt')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 08b7e55d..adfac99c 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -78,9 +78,9 @@ public abstract class StructuredFormatService(val locationService: LocationServi } fun appendDescription(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { - val described = nodes.filter { !it.content.isEmpty } + val described = nodes.filter { it.hasDescription() } if (described.any()) { - val single = described.size == 1 + val single = described.size() == 1 appendHeader(to, "Description", 3) for (node in described) { if (!single) { @@ -89,10 +89,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi appendLine(to, formatText(location, node.content.description)) appendLine(to) for ((label, section) in node.content.sections) { - if (label.startsWith("$")) - continue - if (node.members.any { it.name == label }) - continue + if (!isDescriptionSection(label, node)) continue appendLine(to, formatStrong(formatText(label))) appendLine(to, formatText(location, section)) } @@ -100,6 +97,17 @@ public abstract class StructuredFormatService(val locationService: LocationServi } } + 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 appendSummary(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { val breakdownBySummary = nodes.groupByTo(LinkedHashMap()) { node -> formatText(location, node.summary) |