blob: 923b2ea819ccb78e09bb7cb6c2245d46d1dd92c3 (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
package org.jetbrains.dokka
import com.sampullara.cli.*
import com.intellij.openapi.util.*
import org.jetbrains.jet.cli.common.messages.*
import org.jetbrains.jet.cli.common.arguments.*
import org.jetbrains.jet.utils.PathUtil
import java.io.File
import org.jetbrains.jet.lang.resolve.name.FqName
import org.jetbrains.dokka.DocumentationNode.Kind
class DokkaArguments {
Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)")
ValueDescription("<path>")
public var src: String? = null
Argument(value = "output", description = "Output directory path for .md files")
ValueDescription("<path>")
public var outputDir: String = "out/doc/"
Argument(value = "module", description = "Name of the documentation module")
ValueDescription("<name>")
public var moduleName: String = ""
Argument(value = "classpath", description = "Classpath for symbol resolution")
ValueDescription("<path>")
public var classpath: String = ""
}
public fun main(args: Array<String>) {
val arguments = DokkaArguments()
val sourceFiles = Args.parse(arguments, args)
val sources: List<String> = sourceFiles ?: listOf()
val environment = AnalysisEnvironment(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR) {
addClasspath(PathUtil.getJdkClassesRoots())
for (element in arguments.classpath.split(File.pathSeparatorChar)) {
addClasspath(File(element))
}
// addClasspath(PathUtil.getKotlinPathsForCompiler().getRuntimePath())
addSources(sources)
}
println("Module: ${arguments.moduleName}")
println("Output: ${arguments.outputDir}")
println("Sources: ${environment.sources.join()}")
println("Classpath: ${environment.classpath.joinToString()}")
println()
print("Analysing sources and libraries... ")
val startAnalyse = System.currentTimeMillis()
val documentation = environment.withContext { environment, module, context ->
val documentationModule = DocumentationModule("test")
val options = DocumentationOptions()
val documentationBuilder = DocumentationBuilder(context, options)
with(documentationBuilder) {
documentationModule.appendFiles(environment.getSourceFiles())
}
documentationBuilder.resolveReferences(documentationModule)
documentationModule
}
val timeAnalyse = System.currentTimeMillis() - startAnalyse
println("done in ${timeAnalyse / 1000} secs")
val startBuild = System.currentTimeMillis()
val signatureGenerator = KotlinLanguageService()
val locationService = FoldersLocationService(arguments.outputDir)
val templateService = HtmlTemplateService.default("/dokka/styles/style.css")
val formatter = HtmlFormatService(locationService, signatureGenerator, templateService)
val generator = FileGenerator(signatureGenerator, locationService, formatter)
print("Building pages... ")
generator.buildPage(documentation)
generator.buildOutline(documentation)
val timeBuild = System.currentTimeMillis() - startBuild
println("done in ${timeBuild / 1000} secs")
println()
println("Done.")
Disposer.dispose(environment)
}
|