diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2017-02-24 13:15:30 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2017-02-24 13:15:30 +0100 |
commit | a3c7641398de9a3cd594a273538bb9e916139830 (patch) | |
tree | ae5748de0641312f2f935d39eb718a5696393ae5 /core/src | |
parent | a962349500918a5e26ae9b5567218986838a1ffb (diff) | |
download | dokka-a3c7641398de9a3cd594a273538bb9e916139830.tar.gz dokka-a3c7641398de9a3cd594a273538bb9e916139830.tar.bz2 dokka-a3c7641398de9a3cd594a273538bb9e916139830.zip |
Omit platform of members when it's the same as the platform of the defining class
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/Formats/StructuredFormatService.kt | 22 | ||||
-rw-r--r-- | core/src/test/kotlin/format/MarkdownFormatTest.kt | 7 |
2 files changed, 19 insertions, 10 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index de2ef3ed..3cfc96a2 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -406,15 +406,15 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, appendSection("Exceptions", node.members(NodeKind.Exception)) appendSection("Type Aliases", node.members(NodeKind.TypeAlias)) appendSection("Extensions for External Classes", node.members(NodeKind.ExternalClass)) - appendSection("Enum Values", node.members(NodeKind.EnumItem), sortMembers = false) - appendSection("Constructors", node.members(NodeKind.Constructor)) - appendSection("Properties", node.members(NodeKind.Property)) + appendSection("Enum Values", node.members(NodeKind.EnumItem), sortMembers = false, omitSamePlatforms = true) + appendSection("Constructors", node.members(NodeKind.Constructor), omitSamePlatforms = true) + appendSection("Properties", node.members(NodeKind.Property), omitSamePlatforms = true) appendSection("Inherited Properties", node.inheritedMembers(NodeKind.Property)) - appendSection("Functions", node.members(NodeKind.Function)) + appendSection("Functions", node.members(NodeKind.Function), omitSamePlatforms = true) appendSection("Inherited Functions", node.inheritedMembers(NodeKind.Function)) - appendSection("Companion Object Properties", node.members(NodeKind.CompanionObjectProperty)) + appendSection("Companion Object Properties", node.members(NodeKind.CompanionObjectProperty), omitSamePlatforms = true) appendSection("Inherited Companion Object Properties", node.inheritedCompanionObjectMembers(NodeKind.Property)) - appendSection("Companion Object Functions", node.members(NodeKind.CompanionObjectFunction)) + appendSection("Companion Object Functions", node.members(NodeKind.CompanionObjectFunction), omitSamePlatforms = true) appendSection("Inherited Companion Object Functions", node.inheritedCompanionObjectMembers(NodeKind.Function)) appendSection("Other members", node.members.filter { it.kind !in setOf( @@ -453,7 +453,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } } - private fun appendSection(caption: String, members: List<DocumentationNode>, sortMembers: Boolean = true) { + private fun appendSection(caption: String, members: List<DocumentationNode>, + sortMembers: Boolean = true, + omitSamePlatforms: Boolean = false) { if (members.isEmpty()) return appendHeader(3) { appendText(caption) } @@ -467,7 +469,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, appendTableRow { appendTableCell { appendLink(memberLocation) - appendPlatforms(members) + appendPlatforms(members, omitSamePlatforms) } appendTableCell { val breakdownBySummary = members.groupBy { it.summary } @@ -502,11 +504,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } } - private fun appendPlatforms(items: List<DocumentationNode>) { + private fun appendPlatforms(items: List<DocumentationNode>, omitSamePlatforms: Boolean) { val platforms = items.foldRight(items.first().platformsToShow.toSet()) { node, platforms -> platforms.intersect(node.platformsToShow) } - if (platforms.isNotEmpty()) { + if (platforms.isNotEmpty() && (platforms != node.platformsToShow.toSet() || !omitSamePlatforms)) { appendLine() to.append("(${platforms.joinToString()})") } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index 7c1cc8b3..fb202b81 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -265,6 +265,13 @@ class MarkdownFormatTest { } } + @Test fun multiplePlatformsOmitRedundant() { + val module = buildMultiplePlatforms("multiplatformOmitRedundant") + verifyModelOutput(module, ".md", "testdata/format/multiplatformOmitRedundant/foo.kt") { model, output -> + markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members) + } + } + @Test fun multiplePlatformsImplied() { val module = buildMultiplePlatforms("multiplatformImplied") verifyModelOutput(module, ".md", "testdata/format/multiplatformImplied/foo.kt") { model, output -> |