diff options
author | Zubakov Aleksey <aleks.zubakov@gmail.com> | 2018-08-17 13:00:06 +0300 |
---|---|---|
committer | Zubakov Aleksey <aleks.zubakov@gmail.com> | 2018-08-17 15:47:47 +0300 |
commit | 1f45cac76a79abb6eaad99b541234cbf34fbce9c (patch) | |
tree | bab06b6ff330b6811ba85f9a48a00dfff82d5646 /core/src/main/kotlin/Generation | |
parent | 39b2f9faf768c185f6bd42a9fde18ceaecb34990 (diff) | |
download | dokka-1f45cac76a79abb6eaad99b541234cbf34fbce9c.tar.gz dokka-1f45cac76a79abb6eaad99b541234cbf34fbce9c.tar.bz2 dokka-1f45cac76a79abb6eaad99b541234cbf34fbce9c.zip |
Merger platforms bug fix, refactoring
Diffstat (limited to 'core/src/main/kotlin/Generation')
-rw-r--r-- | core/src/main/kotlin/Generation/DocumentationMerger.kt | 58 | ||||
-rw-r--r-- | core/src/main/kotlin/Generation/DokkaGenerator.kt | 19 |
2 files changed, 24 insertions, 53 deletions
diff --git a/core/src/main/kotlin/Generation/DocumentationMerger.kt b/core/src/main/kotlin/Generation/DocumentationMerger.kt index c2089821..c4a40df6 100644 --- a/core/src/main/kotlin/Generation/DocumentationMerger.kt +++ b/core/src/main/kotlin/Generation/DocumentationMerger.kt @@ -22,7 +22,6 @@ class DocumentationMerger( producedNodeRefGraph = NodeReferenceGraph() documentationModules.map { it.nodeRefGraph } .flatMap { it.references } - .distinct() .forEach { producedNodeRefGraph.addReference(it) } } @@ -30,7 +29,6 @@ class DocumentationMerger( from: DocumentationNode, packages: List<DocumentationReference> ): List<DocumentationReference> { - val packagesByName = packages .map { it.to } .groupBy { it.name } @@ -63,11 +61,13 @@ class DocumentationMerger( } oldToNewNodeMap[packageNode] = mergedPackage } - mergedPackage.clear() val references = packages.flatMap { it.allReferences() } val mergedReferences = mergeReferences(mergedPackage, references) - for (ref in mergedReferences.distinct()) { + for (ref in mergedReferences) { + if (ref.kind == RefKind.Owner) { + continue + } mergedPackage.addReference(ref) } @@ -76,8 +76,6 @@ class DocumentationMerger( return mergedPackage } - private fun DocumentationNode.clear() = dropReferences { true } - private fun mergeMembers( from: DocumentationNode, refs: List<DocumentationReference> @@ -106,24 +104,17 @@ class DocumentationMerger( ): DocumentationNode { val singleNode = refs.singleOrNull() if (singleNode != null) { - singleNode.owner?.let { owner -> - singleNode.dropReferences { it.to == owner && it.kind == RefKind.Owner } - } + singleNode.dropReferences { it.kind == RefKind.Owner } return singleNode } val groupNode = DocumentationNode(refs.first().name, Content.Empty, NodeKind.GroupNode) groupNode.appendTextNode(signature, NodeKind.Signature, RefKind.Detail) for (node in refs) { - if (node != groupNode) { - node.owner?.let { owner -> - node.dropReferences { it.to == owner && it.kind == RefKind.Owner } - from.dropReferences { it.to == node && it.kind == RefKind.Member } - } - groupNode.append(node, RefKind.Member) + node.dropReferences { it.kind == RefKind.Owner } + groupNode.append(node, RefKind.Member) - oldToNewNodeMap[node] = groupNode - } + oldToNewNodeMap[node] = groupNode } return groupNode } @@ -140,25 +131,7 @@ class DocumentationMerger( val mergedMembers = mergeMembers(from, refsToMembers) // TODO: think about - return mergedPackages + (mergedMembers + refsNotToMembers).distinctBy { - it.to.kind to it.to.name - } - } - - - private fun updatePendingReferences() { - producedNodeRefGraph.references.forEach { - it.lazyNodeFrom.update() - it.lazyNodeTo.update() - } - } - - private fun NodeResolver.update() { - if (this is NodeResolver.Exact) { - if (exactNode != null && oldToNewNodeMap.containsKey(exactNode!!)) { - exactNode = oldToNewNodeMap[exactNode!!] - } - } + return mergedPackages + mergedMembers + refsNotToMembers } fun merge(): DocumentationModule { @@ -175,5 +148,18 @@ class DocumentationMerger( return mergedDocumentationModule } + private fun updatePendingReferences() { + for (ref in producedNodeRefGraph.references) { + ref.lazyNodeFrom.update() + ref.lazyNodeTo.update() + } + } + private fun NodeResolver.update() { + if (this is NodeResolver.Exact) { + if (exactNode != null && exactNode!! in oldToNewNodeMap) { + exactNode = oldToNewNodeMap[exactNode!!] + } + } + } }
\ No newline at end of file diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt index 37f62ed6..1193657e 100644 --- a/core/src/main/kotlin/Generation/DokkaGenerator.kt +++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt @@ -69,13 +69,13 @@ class DokkaGenerator(val dokkaConfiguration: DokkaConfiguration, logger.info("Analysing sources and libraries... ") val startAnalyse = System.currentTimeMillis() - val defaultPlatformAsList = listOf(passConfiguration.analysisPlatform.key) + val defaultPlatformAsList = passConfiguration.targets val defaultPlatformsProvider = object : DefaultPlatformsProvider { override fun getDefaultPlatforms(descriptor: DeclarationDescriptor): List<String> { val containingFilePath = descriptor.sourcePsi()?.containingFile?.virtualFile?.canonicalPath ?.let { File(it).absolutePath } val sourceRoot = containingFilePath?.let { path -> sourceRoots.find { path.startsWith(it.path) } } - return sourceRoot?.platforms ?: defaultPlatformAsList + return /*sourceRoot?.platforms ?: */defaultPlatformAsList } } @@ -83,12 +83,6 @@ class DokkaGenerator(val dokkaConfiguration: DokkaConfiguration, DokkaAnalysisModule(environment, dokkaConfiguration, defaultPlatformsProvider, documentationModule.nodeRefGraph, passConfiguration, logger)) buildDocumentationModule(injector, documentationModule, { isNotSample(it, passConfiguration.samples) }, includes) - documentationModule.visit { it -> - it.addReferenceTo( - DocumentationNode(analysisPlatform.key, Content.Empty, NodeKind.Platform), - RefKind.Platform - ) - } val timeAnalyse = System.currentTimeMillis() - startAnalyse logger.info("done in ${timeAnalyse / 1000} secs") @@ -96,15 +90,6 @@ class DokkaGenerator(val dokkaConfiguration: DokkaConfiguration, Disposer.dispose(environment) } - private fun DocumentationNode.visit(action: (DocumentationNode) -> Unit) { - action(this) - - for (member in members) { - member.visit(action) - } - } - - fun createAnalysisEnvironment( sourcePaths: List<String>, passConfiguration: DokkaConfiguration.PassConfiguration |