aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Analysis/AnalysisEnvironment.kt6
-rw-r--r--src/Analysis/CompilerAPI.kt3
-rw-r--r--src/Model/DocumentationModule.kt14
-rw-r--r--src/Model/DocumentationNodeBuilder.kt6
-rw-r--r--src/main.kt11
5 files changed, 24 insertions, 16 deletions
diff --git a/src/Analysis/AnalysisEnvironment.kt b/src/Analysis/AnalysisEnvironment.kt
index 20c1a764..d657ae4a 100644
--- a/src/Analysis/AnalysisEnvironment.kt
+++ b/src/Analysis/AnalysisEnvironment.kt
@@ -20,14 +20,14 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A
body()
}
- private fun withContext<T>(processor: (JetCoreEnvironment, ModuleDescriptor, BindingContext) -> T): T {
+ public fun withContext<T>(processor: (JetCoreEnvironment, ModuleDescriptor, BindingContext) -> T): T {
val environment = JetCoreEnvironment.createForProduction(this, configuration)
val exhaust = environment.analyze(messageCollector)
return processor(environment, exhaust.getModuleDescriptor(), exhaust.getBindingContext())
}
- public fun withContext<T>(processor: (BindingContext) -> T): T {
- return withContext { environment, module, context -> processor(context) }
+ public fun withContext<T>(processor: (ModuleDescriptor, BindingContext) -> T): T {
+ return withContext { environment, module, context -> processor(module, context) }
}
public fun streamFiles<T>(processor: (BindingContext, JetFile) -> T): Stream<T> {
diff --git a/src/Analysis/CompilerAPI.kt b/src/Analysis/CompilerAPI.kt
index bc0e6e93..b2b9a824 100644
--- a/src/Analysis/CompilerAPI.kt
+++ b/src/Analysis/CompilerAPI.kt
@@ -53,10 +53,11 @@ fun JetCoreEnvironment.analyze(messageCollector: MessageCollector): AnalyzeExhau
fun AnalyzerWithCompilerReport.analyzeAndReport(files: List<JetFile>, analyser: () -> AnalyzeExhaust) = analyzeAndReport(analyser, files)
-fun BindingContext.getPackageFragment(file: JetFile) = get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file)
+fun BindingContext.getPackageFragment(file: JetFile) : PackageFragmentDescriptor? = get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file)
fun DeclarationDescriptor.isUserCode() =
when (this) {
+ is PackageViewDescriptor -> false
is PackageFragmentDescriptor -> false
is PropertyAccessorDescriptor -> !isDefault()
is CallableMemberDescriptor -> getKind() == CallableMemberDescriptor.Kind.DECLARATION
diff --git a/src/Model/DocumentationModule.kt b/src/Model/DocumentationModule.kt
index 1f30268e..6b2773ed 100644
--- a/src/Model/DocumentationModule.kt
+++ b/src/Model/DocumentationModule.kt
@@ -1,8 +1,8 @@
package org.jetbrains.dokka
import org.jetbrains.jet.lang.resolve.BindingContext
-import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.lang.descriptors.*
+import org.jetbrains.jet.lang.resolve.name.FqName
public class DocumentationModule(val module: ModuleDescriptor) : DocumentationNode(module, "module", DocumentationContent.Empty, DocumentationNode.Kind.Module) {
fun merge(other: DocumentationModule): DocumentationModule {
@@ -13,15 +13,13 @@ public class DocumentationModule(val module: ModuleDescriptor) : DocumentationNo
}
}
-fun BindingContext.createDocumentationModule(module: ModuleDescriptor, file: JetFile): DocumentationModule {
- val packageFragment = getPackageFragment(file)
+fun BindingContext.createDocumentationModule(module: ModuleDescriptor, packages: Set<FqName>): DocumentationModule {
val documentationModule = DocumentationModule(module)
- if (packageFragment == null) throw IllegalArgumentException("File $file should have package fragment")
-
val visitor = DocumentationNodeBuilder(this)
- packageFragment.accept(DocumentationBuildingVisitor(this, visitor), documentationModule)
-
+ for (packageName in packages) {
+ val pkg = module.getPackage(packageName)
+ pkg!!.accept(DocumentationBuildingVisitor(this, visitor), documentationModule)
+ }
checkResolveChildren(documentationModule)
-
return documentationModule
}
diff --git a/src/Model/DocumentationNodeBuilder.kt b/src/Model/DocumentationNodeBuilder.kt
index f974ab11..8d75a45c 100644
--- a/src/Model/DocumentationNodeBuilder.kt
+++ b/src/Model/DocumentationNodeBuilder.kt
@@ -130,6 +130,12 @@ class DocumentationNodeBuilder(val context: BindingContext) : DeclarationDescrip
return node
}
+ override fun visitPackageViewDescriptor(descriptor: PackageViewDescriptor?, data: DocumentationNode?): DocumentationNode? {
+ val node = DocumentationNode(descriptor!!, descriptor.getFqName().asString(), DocumentationContent.Empty, DocumentationNode.Kind.Package)
+ reference(data!!, node, DocumentationReference.Kind.Member)
+ return node
+ }
+
override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = DocumentationNode(descriptor!!, descriptor.fqName.asString(), DocumentationContent.Empty, DocumentationNode.Kind.Package)
reference(data!!, node, DocumentationReference.Kind.Member)
diff --git a/src/main.kt b/src/main.kt
index fbbb53d6..56717a80 100644
--- a/src/main.kt
+++ b/src/main.kt
@@ -35,10 +35,13 @@ public fun main(args: Array<String>) {
println()
- val documentation = environment.processFiles { context, module, file ->
- println("Processing: ${file.getName()}")
- context.createDocumentationModule(module, file)
- }.reduce {(aggregate, item) -> aggregate.merge(item) }
+ val documentation = environment.withContext<DocumentationModule> { environment, module, context ->
+ val packageSet = environment.getSourceFiles().map { file ->
+ context.getPackageFragment(file)!!.fqName
+ }.toSet()
+
+ context.createDocumentationModule(module, packageSet)
+ }
val signatureGenerator = KotlinSignatureGenerator()
val locationService = FoldersLocationService(arguments.outputDir ?: "out/doc/")