diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-23 18:52:05 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-23 18:52:05 +0100 |
commit | 76e4d3cbc7cbbe1d35fb2e0c1ba59d3c86e0daf2 (patch) | |
tree | efc5fc2e5dce290fbca9d55c12f0056b96735c3b /src/Formats | |
parent | 73bd875b621fedce84015c50b6954509f4978a6d (diff) | |
download | dokka-76e4d3cbc7cbbe1d35fb2e0c1ba59d3c86e0daf2.tar.gz dokka-76e4d3cbc7cbbe1d35fb2e0c1ba59d3c86e0daf2.tar.bz2 dokka-76e4d3cbc7cbbe1d35fb2e0c1ba59d3c86e0daf2.zip |
parse included Markdown files to retrieve documentation for modules and packages
Diffstat (limited to 'src/Formats')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 233dd9e3..0ee3c888 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -84,12 +84,9 @@ public abstract class StructuredFormatService(locationService: LocationService, append(formatLink(linkText, content.href)) } } - is ContentParagraph -> { - appendParagraph(this, formatText(location, content.children)) - } - is ContentBlockCode -> { - appendBlockCode(this, formatText(location, content.children), content.language) - } + is ContentParagraph -> appendParagraph(this, formatText(location, content.children)) + is ContentBlockCode -> appendBlockCode(this, formatText(location, content.children), content.language) + is ContentHeading -> appendHeader(this, formatText(location, content.children), content.level) is ContentBlock -> append(formatText(location, content.children)) } }.toString() @@ -133,6 +130,9 @@ public abstract class StructuredFormatService(locationService: LocationService, } } + private fun DocumentationNode.isModuleOrPackage(): Boolean = + kind == DocumentationNode.Kind.Module || kind == DocumentationNode.Kind.Package + protected open fun appendAsSignature(to: StringBuilder, block: () -> Unit) { block() } @@ -206,10 +206,18 @@ public abstract class StructuredFormatService(locationService: LocationService, } fun appendLocation(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { - val breakdownByName = nodes.groupBy { node -> node.name } - for ((name, items) in breakdownByName) { - appendHeader(to, formatText(name)) - appendDocumentation(location, to, items) + val singleNode = nodes.singleOrNull() + if (singleNode != null && singleNode.isModuleOrPackage()) { + if (singleNode.kind == DocumentationNode.Kind.Package) { + appendHeader(to, "Package " + formatText(singleNode.name), 2) + } + to.append(formatText(location, singleNode.content)) + } else { + val breakdownByName = nodes.groupBy { node -> node.name } + for ((name, items) in breakdownByName) { + appendHeader(to, formatText(name)) + appendDocumentation(location, to, items) + } } } |