diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-08 18:51:30 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-08 18:51:30 +0100 |
commit | b7db2d39e75d88347a006ef3d8c16ee715cb43ec (patch) | |
tree | f98b87409f1fd8f73e3a67178ff0cadb0221920a /core/src/main | |
parent | 057c331c89ce72d72392508130d07986d392ffa4 (diff) | |
download | dokka-b7db2d39e75d88347a006ef3d8c16ee715cb43ec.tar.gz dokka-b7db2d39e75d88347a006ef3d8c16ee715cb43ec.tar.bz2 dokka-b7db2d39e75d88347a006ef3d8c16ee715cb43ec.zip |
move some more logic into PageBuilder class
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/Formats/StructuredFormatService.kt | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index e5fd4675..d830fda7 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -126,42 +126,6 @@ abstract class StructuredFormatService(locationService: LocationService, fun Content.getSectionsWithSubjects(): Map<String, List<ContentSection>> = sections.filter { it.subjectName != null }.groupBy { it.tag } - private fun DocumentationNode.appendOverrides(to: StringBuilder) { - overrides.forEach { - to.append("Overrides ") - val location = locationService.relativePathToLocation(this, it) - appendLine(to, formatLink(FormatLink(it.owner!!.name + "." + it.name, location))) - } - } - - private fun DocumentationNode.appendDeprecation(location: Location, to: StringBuilder) { - if (deprecation != null) { - val deprecationParameter = deprecation!!.details(NodeKind.Parameter).firstOrNull() - val deprecationValue = deprecationParameter?.details(NodeKind.Value)?.firstOrNull() - if (deprecationValue != null) { - to.append(formatStrong("Deprecated:")).append(" ") - appendLine(to, formatText(deprecationValue.name.removeSurrounding("\""))) - appendLine(to) - } else if (deprecation?.content != Content.Empty) { - to.append(formatStrong("Deprecated:")).append(" ") - formatText(location, deprecation!!.content, to) - } else { - appendLine(to, formatStrong("Deprecated")) - appendLine(to) - } - } - } - - private fun DocumentationNode.appendSourceLink(to: StringBuilder) { - val sourceUrl = details(NodeKind.SourceUrl).firstOrNull() - if (sourceUrl != null) { - to.append(" ") - appendLine(to, formatLink("(source)", sourceUrl.name)) - } else { - appendLine(to) - } - } - private fun ContentNode.signatureToText(location: Location): String { return if (this is ContentBlock && this.isEmpty()) { "" @@ -221,10 +185,10 @@ abstract class StructuredFormatService(locationService: LocationService, val rendered = languageService.render(it) appendAsSignature(to, rendered) { to.append(formatCode(formatText(location, rendered))) - it.appendSourceLink(to) + it.appendSourceLink() } - it.appendOverrides(to) - it.appendDeprecation(location, to) + it.appendOverrides() + it.appendDeprecation() } // All items have exactly the same documentation, so we can use any item to render it val item = items.first() @@ -232,21 +196,57 @@ abstract class StructuredFormatService(locationService: LocationService, formatText(location, it.content, to) } formatText(location, item.content.summary, to) - appendDescription(item) + item.appendDescription() appendLine(to) appendLine(to) } - private fun appendDescription(node: DocumentationNode) { - if (node.content.description != ContentEmpty) { - appendLine(to, formatText(location, node.content.description)) + private fun DocumentationNode.appendSourceLink() { + val sourceUrl = details(NodeKind.SourceUrl).firstOrNull() + if (sourceUrl != null) { + to.append(" ") + appendLine(to, formatLink("(source)", sourceUrl.name)) + } else { + appendLine(to) + } + } + + private fun DocumentationNode.appendOverrides() { + overrides.forEach { + to.append("Overrides ") + val location = locationService.relativePathToLocation(this, it) + appendLine(to, formatLink(FormatLink(it.owner!!.name + "." + it.name, location))) + } + } + + private fun DocumentationNode.appendDeprecation() { + if (deprecation != null) { + val deprecationParameter = deprecation!!.details(NodeKind.Parameter).firstOrNull() + val deprecationValue = deprecationParameter?.details(NodeKind.Value)?.firstOrNull() + if (deprecationValue != null) { + to.append(formatStrong("Deprecated:")).append(" ") + appendLine(to, formatText(deprecationValue.name.removeSurrounding("\""))) + appendLine(to) + } else if (deprecation?.content != Content.Empty) { + to.append(formatStrong("Deprecated:")).append(" ") + formatText(location, deprecation!!.content, to) + } else { + appendLine(to, formatStrong("Deprecated")) + appendLine(to) + } + } + } + + private fun DocumentationNode.appendDescription() { + if (content.description != ContentEmpty) { + appendLine(to, formatText(location, content.description)) appendLine(to) } - node.content.getSectionsWithSubjects().forEach { + content.getSectionsWithSubjects().forEach { appendSectionWithSubject(it.key, it.value) } - for (section in node.content.sections.filter { it.subjectName == null }) { + for (section in content.sections.filter { it.subjectName == null }) { appendLine(to, formatStrong(formatText(section.tag))) appendLine(to, formatText(location, section)) } |