diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2017-02-23 19:08:31 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2017-02-23 19:08:31 +0100 |
commit | ff8fdb0bbc4069773424400acfdce36a4e3d6d6a (patch) | |
tree | ced42fb0bc0690191fc8836a47e3a4e19765e563 /core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | |
parent | 66757b43bb48d52e4fb92d38e9a893ab40d1d63e (diff) | |
download | dokka-ff8fdb0bbc4069773424400acfdce36a4e3d6d6a.tar.gz dokka-ff8fdb0bbc4069773424400acfdce36a4e3d6d6a.tar.bz2 dokka-ff8fdb0bbc4069773424400acfdce36a4e3d6d6a.zip |
Resolve link and generate alltypes only once, not after every platform
Diffstat (limited to 'core/src/main/kotlin/Kotlin/DocumentationBuilder.kt')
-rw-r--r-- | core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index ce957d93..70c3565f 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -39,7 +39,7 @@ data class DocumentationOptions(val outputDir: String, val skipDeprecated: Boolean = false, val jdkVersion: Int = 6, val generateIndexPages: Boolean = true, - val sourceLinks: List<SourceLinkDefinition>, + val sourceLinks: List<SourceLinkDefinition> = emptyList(), val impliedPlatforms: List<String> = emptyList()) private fun isExtensionForExternalClass(extensionFunctionDescriptor: DeclarationDescriptor, @@ -344,9 +344,6 @@ class DocumentationBuilder } propagateExtensionFunctionsToSubclasses(fragments) - if (options.generateIndexPages) { - generateAllTypesNode() - } } private fun propagateExtensionFunctionsToSubclasses(fragments: Collection<PackageFragmentDescriptor>) { @@ -419,19 +416,6 @@ class DocumentationBuilder return false } - private fun DocumentationNode.generateAllTypesNode() { - val allTypes = members(NodeKind.Package) - .flatMap { it.members.filter { it.kind in NodeKind.classLike || it.kind == NodeKind.ExternalClass } } - .sortedBy { if (it.kind == NodeKind.ExternalClass) it.name.substringAfterLast('.') else it.name } - - val allTypesNode = DocumentationNode("alltypes", Content.Empty, NodeKind.AllTypes) - for (typeNode in allTypes) { - allTypesNode.addReferenceTo(typeNode, RefKind.Member) - } - - append(allTypesNode, RefKind.Member) - } - fun DeclarationDescriptor.build(): DocumentationNode = when (this) { is ClassDescriptor -> build() is ConstructorDescriptor -> build() @@ -907,3 +891,23 @@ fun DeclarationDescriptor.sourceLocation(): String? { } return null } + +fun DocumentationModule.prepareForGeneration(options: DocumentationOptions) { + if (options.generateIndexPages) { + generateAllTypesNode() + } + nodeRefGraph.resolveReferences() +} + +fun DocumentationNode.generateAllTypesNode() { + val allTypes = members(NodeKind.Package) + .flatMap { it.members.filter { it.kind in NodeKind.classLike || it.kind == NodeKind.ExternalClass } } + .sortedBy { if (it.kind == NodeKind.ExternalClass) it.name.substringAfterLast('.') else it.name } + + val allTypesNode = DocumentationNode("alltypes", Content.Empty, NodeKind.AllTypes) + for (typeNode in allTypes) { + allTypesNode.addReferenceTo(typeNode, RefKind.Member) + } + + append(allTypesNode, RefKind.Member) +} |