blob: 04415070031d61443bd901407949c213a17add84 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package com.jetbrains.dokka
import com.sampullara.cli.*
import com.intellij.openapi.util.*
import org.jetbrains.jet.cli.common.messages.*
import org.jetbrains.jet.utils.*
import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
public fun main(args: Array<String>) {
val compilerArguments = K2JVMCompilerArguments()
val sources: List<String> = Args.parse(compilerArguments, args) ?: listOf()
val environment = AnalysesEnvironment(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR) {
/*
addClasspath(PathUtil.getJdkClassesRoots())
addClasspath(PathUtil.getKotlinPathsForCompiler().getRuntimePath())
*/
addSources(sources)
}
println("Dokka is preparing sources and libraries...")
println("Sources: ${environment.sources.join()}")
println("Classpath: ${environment.classpath.joinToString()}")
println()
val results = environment.processFiles { context, file ->
println("Processing: ${file.getName()}")
println()
context.analyseFile(file)
}
println()
println("Results:")
results.forEach {
println(it)
}
Disposer.dispose(environment)
}
fun BindingContext.analyseFile(file: JetFile) {
val packageFragment = getPackageFragment(file)
if (packageFragment == null) {
println("PackageFragment is null")
return
}
println("Package: ${packageFragment}")
for (descriptor in packageFragment.getMemberScope().getAllDescriptors()) {
println("Member: ${descriptor}")
val doc = getDocumentation(descriptor)
if (doc != null) {
println("Comment:\n${doc.getText()}")
}
println()
}
}
|