From 72b011070b3203ea0de2982c3857940b6ef05c82 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 15 Nov 2015 19:12:18 -0800 Subject: [PATCH] Source links for dokka. --- .../beust/kobalt/plugin/dokka/DokkaPlugin.kt | 42 +++++++++++-------- src/main/resources/META-INF/plugin.xml | 1 + 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt index f98b7159..72897f97 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt @@ -12,6 +12,7 @@ import com.beust.kobalt.api.annotation.Task import com.beust.kobalt.internal.JvmCompilerPlugin import com.beust.kobalt.maven.DepFactory import com.beust.kobalt.misc.RunCommand +import com.beust.kobalt.misc.error import com.beust.kobalt.misc.log import java.io.File import javax.inject.Inject @@ -42,40 +43,47 @@ class DokkaPlugin @Inject constructor(val depFactory: DepFactory) : ConfigPlugin listOf(buildDir)) .joinToString(File.pathSeparator) val dokkaJar = JarFinder.byId(DOKKA_ID) + var success = true if (config != null) { val args : List = listOf( "-classpath", classpathString, "-jar", dokkaJar.absolutePath, - "src/main/kotlin") + + *(project.sourceDirectories.toTypedArray())) + config.args - RunCommand(javaExecutable.absolutePath).run(args, successCallback = { - println("COMMAND SUCCESS") + RunCommand(javaExecutable.absolutePath).run(args, errorCallback = { output: List -> + error("Error running dokka:\n " + output.joinToString("\n")) + success = false }) } else { log(2, "No dokka configuration found for project ${project.name}, skipping it") } - return TaskResult() + return TaskResult(success) } } -/* -output - the output directory where the documentation is generated -format - the output format: -html - HTML (default) -markdown - Markdown -jekyll - Markdown adapted for Jekyll sites -javadoc - Javadoc (showing how the project can be accessed from Java) -classpath - list of directories or .jar files to include in the classpath (used for resolving references) -samples - list of directories containing sample code (documentation for those directories is not generated but declarations from them can be referenced using the @sample tag) -module - the name of the module being documented (used as the root directory of the generated documentation) -include - names of files containing the documentation for the module and individual packages -nodeprecated - */ class DokkaConfig() { val args = arrayListOf() fun args(vararg options: String) { args.addAll(options) } + + var linkMapping: LinkMappingConfig? = null + + @Directive + fun linkMapping(init: LinkMappingConfig.() -> Unit) { + let { project -> + linkMapping = LinkMappingConfig().let { + it.init() + it + } + } + } +} + +class LinkMappingConfig { + var dir: String = "" + var url: String = "" + var suffix: String? = null } @Directive diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 9e9fec37..efe2133d 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -10,6 +10,7 @@ com.beust.kobalt.plugin.packaging.PackagingPlugin com.beust.kobalt.plugin.publish.PublishPlugin com.beust.kobalt.plugin.apt.AptPlugin + com.beust.kobalt.plugin.dokka.DokkaPlugin com.beust.kobalt.plugin.android.AndroidPlugin