diff options
author | Dmitry Jemerov <intelliyole@gmail.com> | 2014-12-29 20:31:08 +0100 |
---|---|---|
committer | Dmitry Jemerov <intelliyole@gmail.com> | 2014-12-29 20:31:08 +0100 |
commit | 41aeba5f437a7d31e4ee34a660e8262ba7d27790 (patch) | |
tree | f91f6ee668a88ba5a73c0edd86bd45604d34571f /src/Formats | |
parent | badba07c1d151ff5a9cf623abecf7f2c906b5931 (diff) | |
parent | c43a437caa047f787bd3bb84ff612f505d0f8efc (diff) | |
download | dokka-41aeba5f437a7d31e4ee34a660e8262ba7d27790.tar.gz dokka-41aeba5f437a7d31e4ee34a660e8262ba7d27790.tar.bz2 dokka-41aeba5f437a7d31e4ee34a660e8262ba7d27790.zip |
Merge pull request #7 from orangy/empty-description
don't generate "Description" header if nothing is going to follow it
Diffstat (limited to 'src/Formats')
-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) |