aboutsummaryrefslogtreecommitdiff
path: root/src/Model/DocumentationModule.kt
blob: 78ebda04beb36ab1eda707856c189a246cf4df6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.jetbrains.dokka

import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.descriptors.*
import org.jetbrains.jet.lang.resolve.name.FqName

public class DocumentationModule(name: String, val module: ModuleDescriptor) : DocumentationNode(module, name, DocumentationContent.Empty, DocumentationNode.Kind.Module) {
    fun merge(other: DocumentationModule): DocumentationModule {
        val model = DocumentationModule(name, module)
        model.addAllReferencesFrom(other)
        model.addAllReferencesFrom(this)
        return model
    }
}

fun BindingContext.createDocumentationModule(name: String,
                                             module: ModuleDescriptor,
                                             packages: Set<FqName>,
                                             options : DocumentationOptions = DocumentationOptions()): DocumentationModule {
    val documentationModule = DocumentationModule(name, module)
    val visitor = DocumentationNodeBuilder(this)
    for (packageName in packages) {
        val pkg = module.getPackage(packageName)
        pkg!!.accept(DocumentationBuildingVisitor(this, options, visitor), documentationModule)
    }

    // TODO: Uncomment for resolve verification
    // checkResolveChildren(documentationModule)
    return documentationModule
}