diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-01-15 18:34:23 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-01-30 19:20:59 +0100 |
commit | f338bc0b6dfa603e369b0c727b6cb256dfc711be (patch) | |
tree | 423df35279c18af53795e7e4e3ced59bd7457f42 /ant/src | |
parent | 0783f6fbe2104334195964bbc91cb584cbbab4e0 (diff) | |
download | dokka-f338bc0b6dfa603e369b0c727b6cb256dfc711be.tar.gz dokka-f338bc0b6dfa603e369b0c727b6cb256dfc711be.tar.bz2 dokka-f338bc0b6dfa603e369b0c727b6cb256dfc711be.zip |
support source links in the Ant task
Diffstat (limited to 'ant/src')
-rw-r--r-- | ant/src/dokka.kt | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ant/src/dokka.kt b/ant/src/dokka.kt index 9510f78b..464dadfe 100644 --- a/ant/src/dokka.kt +++ b/ant/src/dokka.kt @@ -7,6 +7,8 @@ import org.apache.tools.ant.BuildException import org.apache.tools.ant.Project import org.jetbrains.dokka.DokkaLogger import org.jetbrains.dokka.DokkaGenerator +import org.jetbrains.dokka.SourceLinkDefinition +import java.io.File class AntLogger(val task: Task): DokkaLogger { override fun info(message: String) = task.log(message, Project.MSG_INFO) @@ -14,6 +16,8 @@ class AntLogger(val task: Task): DokkaLogger { override fun error(message: String) = task.log(message, Project.MSG_ERR) } +class AntSourceLinkDefinition(var path: String? = null, var url: String? = null, var lineSuffix: String? = null) + class DokkaAntTask(): Task() { public var moduleName: String? = null public var outputDir: String? = null @@ -24,6 +28,8 @@ class DokkaAntTask(): Task() { public val samplesPath: Path = Path(getProject()) public val includesPath: Path = Path(getProject()) + public val antSourceLinks: MutableList<AntSourceLinkDefinition> = arrayListOf() + public fun setClasspath(classpath: Path) { compileClasspath.append(classpath) } @@ -54,6 +60,12 @@ class DokkaAntTask(): Task() { includesPath.append(include) } + public fun createSourceLink(): AntSourceLinkDefinition { + val def = AntSourceLinkDefinition() + antSourceLinks.add(def) + return def + } + override fun execute() { if (sourcePath.list().size() == 0) { throw BuildException("At least one source path needs to be specified") @@ -64,6 +76,17 @@ class DokkaAntTask(): Task() { if (outputDir == null) { throw BuildException("Output directory needs to be specified") } + val sourceLinks = antSourceLinks.map { + val path = it.path + if (path == null) { + throw BuildException("Path attribute of a <sourceLink> element is required") + } + val url = it.url + if (url == null) { + throw BuildException("Path attribute of a <sourceLink> element is required") + } + SourceLinkDefinition(File(path).getCanonicalFile().getAbsolutePath(), url, it.lineSuffix) + } val url = javaClass<DokkaAntTask>().getResource("/org/jetbrains/dokka/ant/DokkaAntTask.class") val jarRoot = url.getPath().substringBefore("!/").trimLeading("file:") @@ -78,7 +101,7 @@ class DokkaAntTask(): Task() { moduleName!!, outputDir!!, outputFormat, - listOf() + sourceLinks ) generator.generate() } |