diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2019-07-09 15:40:32 +0200 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2019-07-09 15:40:32 +0200 |
commit | 44a6ca53ca434f4300e81677a8d6814e30840280 (patch) | |
tree | 1c48f1cb137fde5bdd6b39c5e6a8d8a3bfb9a326 /core/src | |
parent | 42e5e47e2c8921596b7b5d5e4394e872f686b07d (diff) | |
download | dokka-44a6ca53ca434f4300e81677a8d6814e30840280.tar.gz dokka-44a6ca53ca434f4300e81677a8d6814e30840280.tar.bz2 dokka-44a6ca53ca434f4300e81677a8d6814e30840280.zip |
Quick and dirty fix for merging extensions for external classes
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/Generation/DocumentationMerger.kt | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/core/src/main/kotlin/Generation/DocumentationMerger.kt b/core/src/main/kotlin/Generation/DocumentationMerger.kt index f58d2f8e..5d53868a 100644 --- a/core/src/main/kotlin/Generation/DocumentationMerger.kt +++ b/core/src/main/kotlin/Generation/DocumentationMerger.kt @@ -40,7 +40,7 @@ class DocumentationMerger( updatePendingReferences() resultReferences.add( - DocumentationReference(from, producedPackage, RefKind.Member) + DocumentationReference(from, producedPackage, RefKind.Member) ) } catch (t: Throwable) { val entries = listOfPackages.joinToString(",") { "references:${it.allReferences().size}" } @@ -137,14 +137,21 @@ class DocumentationMerger( 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 } - } + .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) + // TODO: Quick and dirty fox for merging extensions for external classes. Fix this probably in StructuredFormatService + // TODO: while refactoring documentation model + + val groupNode = if(nodes.first().kind == NodeKind.ExternalClass){ + DocumentationNode(nodes.first().name, Content.Empty, NodeKind.ExternalClass) + } else { + DocumentationNode(nodes.first().name, Content.Empty, NodeKind.GroupNode) + } groupNode.appendTextNode(signature, NodeKind.Signature, RefKind.Detail) for (node in nodes) { @@ -155,6 +162,11 @@ class DocumentationMerger( oldToNewNodeMap[node] = groupNode } + if (groupNode.kind == NodeKind.ExternalClass){ + val refs = nodes.flatMap { it.allReferences() }.filter { it.kind != RefKind.Owner && it.kind != RefKind.TopLevelPage } + refs.forEach { it.to.append(groupNode, RefKind.TopLevelPage); groupNode.append(it.to, RefKind.Member) } + } + // if nodes are classes, nested members should be also merged and // inserted at the same level with class if (nodes.all { it.kind in NodeKind.classLike }) { |