diff options
-rw-r--r-- | core/src/main/kotlin/Generation/DocumentationMerger.kt | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/core/src/main/kotlin/Generation/DocumentationMerger.kt b/core/src/main/kotlin/Generation/DocumentationMerger.kt index b29c2915..f58d2f8e 100644 --- a/core/src/main/kotlin/Generation/DocumentationMerger.kt +++ b/core/src/main/kotlin/Generation/DocumentationMerger.kt @@ -127,12 +127,21 @@ class DocumentationMerger( singleNode.dropReferences { it.kind == RefKind.Owner } return singleNode } - val nodeWithMaxPlatforms = nodes.maxBy { it.platforms.size }!! - val maxPlatforms = nodeWithMaxPlatforms.platforms.toSet() - val notContained = nodes.filterNot { maxPlatforms.containsAll(it.platforms) } - val reducedDuplicates = listOf(nodeWithMaxPlatforms) + notContained - if (!reducedDuplicates.containsAll(nodes)) { - return mergeMembersWithEqualSignature(signature, reducedDuplicates) + + // Specialization processing + // Given (Common, JVM, JRE6, JS) and (JVM, JRE6) and (JVM, JRE7) + // Sorted: (JVM, JRE6), (JVM, JRE7), (Common, JVM, JRE6, JS) + // Should output: (JVM, JRE6), (JVM, JRE7), (Common, JS) + // Should not remove first platform + val nodesSortedByPlatformCount = nodes.sortedBy { it.platforms.size } + val allPlatforms = mutableSetOf<String>() + nodesSortedByPlatformCount.forEach { node -> + node.platforms + .filterNot { allPlatforms.add(it) } + .filter { it != node.platforms.first() } + .forEach { platform -> + node.dropReferences { it.kind == RefKind.Platform && it.to.name == platform } + } } val groupNode = DocumentationNode(nodes.first().name, Content.Empty, NodeKind.GroupNode) |