aboutsummaryrefslogtreecommitdiff
path: root/runners/cli
diff options
context:
space:
mode:
authorSimon Ogorodnik <sem-oro@yandex.ru>2016-11-01 02:10:32 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-01 14:46:01 +0300
commit769701f99a1aefbc9d385c1938c9c7d3a7b2e38e (patch)
treec3ea4802d9e627c90870808aba9343eb224a114c /runners/cli
parent08bcaa257f7b48929af6ee29007dd6f0d7bb1b52 (diff)
downloaddokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.tar.gz
dokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.tar.bz2
dokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.zip
Total build refactoring, prepare for new development iteration
Removed old and useless build helpers Remove old .xml's from .idea and add .idea/shelf to .gitignore build-docs.xml fixed, dokka_version set to 0.9.10
Diffstat (limited to 'runners/cli')
-rw-r--r--runners/cli/build.gradle6
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt92
2 files changed, 98 insertions, 0 deletions
diff --git a/runners/cli/build.gradle b/runners/cli/build.gradle
new file mode 100644
index 00000000..2dbaa793
--- /dev/null
+++ b/runners/cli/build.gradle
@@ -0,0 +1,6 @@
+sourceCompatibility = 1.5
+
+dependencies {
+ compile project(":core")
+ compile "com.github.spullara.cli-parser:cli-parser:1.1.1"
+}
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
new file mode 100644
index 00000000..f4e81241
--- /dev/null
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -0,0 +1,92 @@
+package org.jetbrains.dokka
+
+import com.sampullara.cli.Args
+import com.sampullara.cli.Argument
+import org.jetbrains.kotlin.cli.common.arguments.ValueDescription
+import java.io.File
+
+class DokkaArguments {
+ @set:Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)")
+ @ValueDescription("<path>")
+ var src: String = ""
+
+ @set:Argument(value = "srcLink", description = "Mapping between a source directory and a Web site for browsing the code")
+ @ValueDescription("<path>=<url>[#lineSuffix]")
+ var srcLink: String = ""
+
+ @set:Argument(value = "include", description = "Markdown files to load (allows many paths separated by the system path separator)")
+ @ValueDescription("<path>")
+ var include: String = ""
+
+ @set:Argument(value = "samples", description = "Source root for samples")
+ @ValueDescription("<path>")
+ var samples: String = ""
+
+ @set:Argument(value = "output", description = "Output directory path")
+ @ValueDescription("<path>")
+ var outputDir: String = "out/doc/"
+
+ @set:Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)")
+ @ValueDescription("<name>")
+ var outputFormat: String = "html"
+
+ @set:Argument(value = "module", description = "Name of the documentation module")
+ @ValueDescription("<name>")
+ var moduleName: String = ""
+
+ @set:Argument(value = "classpath", description = "Classpath for symbol resolution")
+ @ValueDescription("<path>")
+ var classpath: String = ""
+
+ @set:Argument(value = "nodeprecated", description = "Exclude deprecated members from documentation")
+ var nodeprecated: Boolean = false
+
+ @set:Argument(value = "jdkVersion", description = "Version of JDK to use for linking to JDK JavaDoc")
+ var jdkVersion: Int = 6
+}
+
+private fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition {
+ val (path, urlAndLine) = srcLink.split('=')
+ return SourceLinkDefinition(File(path).absolutePath,
+ urlAndLine.substringBefore("#"),
+ urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#" + it })
+}
+
+fun main(args: Array<String>) {
+ val arguments = DokkaArguments()
+ val freeArgs: List<String> = Args.parse(arguments, args) ?: listOf()
+ val sources = if (arguments.src.isNotEmpty()) arguments.src.split(File.pathSeparatorChar).toList() + freeArgs else freeArgs
+ val samples = if (arguments.samples.isNotEmpty()) arguments.samples.split(File.pathSeparatorChar).toList() else listOf()
+ val includes = if (arguments.include.isNotEmpty()) arguments.include.split(File.pathSeparatorChar).toList() else listOf()
+
+ val sourceLinks = if (arguments.srcLink.isNotEmpty() && arguments.srcLink.contains("="))
+ listOf(parseSourceLinkDefinition(arguments.srcLink))
+ else {
+ if (arguments.srcLink.isNotEmpty()) {
+ println("Warning: Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.")
+ }
+ listOf()
+ }
+
+ val classPath = arguments.classpath.split(File.pathSeparatorChar).toList()
+
+ val documentationOptions = DocumentationOptions(
+ arguments.outputDir.let { if (it.endsWith('/')) it else it + '/' },
+ arguments.outputFormat,
+ skipDeprecated = arguments.nodeprecated,
+ sourceLinks = sourceLinks
+ )
+
+ val generator = DokkaGenerator(
+ DokkaConsoleLogger,
+ classPath,
+ sources,
+ samples,
+ includes,
+ arguments.moduleName,
+ documentationOptions)
+
+ generator.generate()
+ DokkaConsoleLogger.report()
+}
+