diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-10-03 04:20:22 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-10-03 04:20:22 +0300 |
commit | 7b1020e2d413602a36b69071385e6b4f406961f3 (patch) | |
tree | ea375d0752e52f53aa6817507c52e732dc939078 /core/src | |
parent | aee7a8e76f2d593a6ba73db1f475acca68b7d693 (diff) | |
download | dokka-7b1020e2d413602a36b69071385e6b4f406961f3.tar.gz dokka-7b1020e2d413602a36b69071385e6b4f406961f3.tar.bz2 dokka-7b1020e2d413602a36b69071385e6b4f406961f3.zip |
Render platforms on overload group level if platforms are similar
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/Formats/StructuredFormatService.kt | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index e12a7923..8b66f187 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -378,13 +378,24 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } private fun formatOverloadGroup(items: List<DocumentationNode>, isSingleNode: Boolean = false) { + + val platformsPerGroup = sameVersionAndPlatforms( + items.flatMap { if (it.kind == NodeKind.GroupNode) it.origins else listOf(it) } + .map { effectivePlatformAndVersion(it) } + ) + + if (platformsPerGroup) { + appendAsPlatformDependentBlock(effectivePlatformAndVersion(items)) { platforms -> + appendPlatforms(platforms) + } + } for ((index, item) in items.withIndex()) { if (index > 0) appendLine() if (item.kind == NodeKind.GroupNode) { - renderGroupNode(item, isSingleNode) + renderGroupNode(item, isSingleNode, !platformsPerGroup) } else { - renderSimpleNode(item, isSingleNode) + renderSimpleNode(item, isSingleNode, !platformsPerGroup) } } @@ -419,7 +430,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } - fun renderSimpleNode(item: DocumentationNode, isSingleNode: Boolean) { + fun renderSimpleNode(item: DocumentationNode, isSingleNode: Boolean, withPlatforms: Boolean = true) { appendAsPlatformDependentBlock(effectivePlatformAndVersion(listOf(item))) { platforms -> // TODO: use summarizesignatures val rendered = languageService.render(item) @@ -427,7 +438,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, if (item.kind !in NodeKind.classLike || !isSingleNode) appendAnchor(it.name) } - appendPlatforms(platforms) + if (withPlatforms) { + appendPlatforms(platforms) + } appendAsSignature(rendered) { appendCode { appendContent(rendered) } item.appendSourceLink() @@ -437,7 +450,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } } - fun renderGroupNode(item: DocumentationNode, isSingleNode: Boolean) { + fun renderGroupNode(item: DocumentationNode, isSingleNode: Boolean, withPlatforms: Boolean = true) { // TODO: use summarizesignatures val groupBySignature = item.origins.groupBy { languageService.render(it) @@ -451,7 +464,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, appendAnchor(it.name) } - appendPlatforms(platforms) + if (withPlatforms) { + appendPlatforms(platforms) + } appendAsSignature(sign) { appendCode { appendContent(sign) } |