diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-05-11 16:31:04 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-05-11 19:54:45 +0300 |
commit | 0e8733ead6d5c4c6db7e4fe8a1f34b7598823290 (patch) | |
tree | c3229a24b1dcab6b0a66dfe65283c041936719b1 /runners | |
parent | a86c859eba6154524f3b42461aad6b45f26e3650 (diff) | |
download | dokka-0e8733ead6d5c4c6db7e4fe8a1f34b7598823290.tar.gz dokka-0e8733ead6d5c4c6db7e4fe8a1f34b7598823290.tar.bz2 dokka-0e8733ead6d5c4c6db7e4fe8a1f34b7598823290.zip |
Add external documentation links argument to gradle, maven, ant
Diffstat (limited to 'runners')
-rw-r--r-- | runners/ant/src/main/kotlin/ant/dokka.kt | 8 | ||||
-rw-r--r-- | runners/cli/src/main/kotlin/cli/main.kt | 7 | ||||
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/main.kt | 12 | ||||
-rw-r--r-- | runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 15 |
4 files changed, 36 insertions, 6 deletions
diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt index f645aea4..83d7e8ac 100644 --- a/runners/ant/src/main/kotlin/ant/dokka.kt +++ b/runners/ant/src/main/kotlin/ant/dokka.kt @@ -6,6 +6,7 @@ import org.apache.tools.ant.Task import org.apache.tools.ant.types.Path import org.apache.tools.ant.types.Reference import org.jetbrains.dokka.* +import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import java.io.File class AntLogger(val task: Task): DokkaLogger { @@ -47,6 +48,7 @@ class DokkaAntTask: Task() { val antSourceLinks: MutableList<AntSourceLinkDefinition> = arrayListOf() val antSourceRoots: MutableList<AntSourceRoot> = arrayListOf() val antPackageOptions: MutableList<AntPackageOptions> = arrayListOf() + val antExternalDocumentationLinks = mutableListOf<ExternalDocumentationLink.Builder>() fun setClasspath(classpath: Path) { compileClasspath.append(classpath) @@ -86,6 +88,8 @@ class DokkaAntTask: Task() { fun createPackageOptions(): AntPackageOptions = AntPackageOptions().apply { antPackageOptions.add(this) } + fun createExternalDocumentationLink() = ExternalDocumentationLink.Builder().apply { antExternalDocumentationLinks.add(this) } + override fun execute() { if (sourcePath.list().isEmpty() && antSourceRoots.isEmpty()) { throw BuildException("At least one source path needs to be specified") @@ -114,7 +118,9 @@ class DokkaAntTask: Task() { sourceLinks = sourceLinks, jdkVersion = jdkVersion, impliedPlatforms = impliedPlatforms.split(','), - perPackageOptions = antPackageOptions) + perPackageOptions = antPackageOptions, + externalDocumentationLinks = antExternalDocumentationLinks.map { it.build() } + ) ) generator.generate() } diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index f8a01c38..ff2107e2 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka +import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import org.jetbrains.kotlin.cli.common.arguments.ValueDescription import org.jetbrains.kotlin.cli.common.parser.com.sampullara.cli.Args import org.jetbrains.kotlin.cli.common.parser.com.sampullara.cli.Argument @@ -61,13 +62,13 @@ class DokkaArguments { object MainKt { - fun parseLinks(links: String): List<DokkaConfiguration.ExternalDocumentationLink> { + fun parseLinks(links: String): List<ExternalDocumentationLink> { val (parsedLinks, parsedOfflineLinks) = links.split("^^") .map { it.split("^").map { it.trim() }.filter { it.isNotBlank() } } .filter { it.isNotEmpty() } .partition { it.size == 1 } - return parsedLinks.map { (root) -> ExternalDocumentationLinkImpl(root) } + + return parsedLinks.map { (root) -> ExternalDocumentationLink.Builder(root).build() } + parsedOfflineLinks.map { (root, packageList) -> val rootUrl = URL(root) val packageListUrl = @@ -76,7 +77,7 @@ object MainKt { } catch (ex: MalformedURLException) { File(packageList).toURI().toURL() } - ExternalDocumentationLinkImpl(rootUrl, packageListUrl) + ExternalDocumentationLink.Builder(rootUrl, packageListUrl).build() } } diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 60311fff..bfa8feea 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -85,6 +85,8 @@ open class DokkaTask : DefaultTask() { @Input var perPackageOptions: MutableList<PackageOptions> = arrayListOf() @Input var impliedPlatforms: MutableList<String> = arrayListOf() + @Input var externalDocumentationLinks = mutableListOf<DokkaConfiguration.ExternalDocumentationLink>() + protected open val sdkProvider: SdkProvider? = null @@ -117,6 +119,13 @@ open class DokkaTask : DefaultTask() { perPackageOptions.add(packageOptions) } + fun externalDocumentationLink(closure: Closure<Any?>) { + val builder = DokkaConfiguration.ExternalDocumentationLink.Builder() + closure.delegate = builder + closure.call() + externalDocumentationLinks.add(builder.build()) + } + fun tryResolveFatJar(project: Project): File { return try { val dependency = project.buildscript.dependencies.create(dokkaFatJar) @@ -185,7 +194,8 @@ open class DokkaTask : DefaultTask() { true, linkMappings, impliedPlatforms, - perPackageOptions) + perPackageOptions, + externalDocumentationLinks) bootstrapProxy.configure( diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index dbae2362..cef0f2d8 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -11,6 +11,7 @@ import org.codehaus.plexus.archiver.Archiver import org.codehaus.plexus.archiver.jar.JarArchiver import org.jetbrains.dokka.* import java.io.File +import java.net.URL class SourceLinkMapItem { @Parameter(name = "dir", required = true) @@ -23,6 +24,14 @@ class SourceLinkMapItem { var urlSuffix: String? = null } +class ExternalDocumentationLinkBuilder : DokkaConfiguration.ExternalDocumentationLink.Builder() { + + @Parameter(name = "url", required = true) + override var url: URL? = null + @Parameter(name = "packageListUrl", required = true) + override var packageListUrl: URL? = null +} + abstract class AbstractDokkaMojo : AbstractMojo() { class SourceRoot : DokkaConfiguration.SourceRoot { @Parameter(required = true) @@ -87,6 +96,9 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter var perPackageOptions: List<PackageOptions> = emptyList() + @Parameter + var externalDocumentationLinks: List<ExternalDocumentationLinkBuilder> = emptyList() + protected abstract fun getOutDir(): String protected abstract fun getOutFormat(): String @@ -110,7 +122,8 @@ abstract class AbstractDokkaMojo : AbstractMojo() { skipEmptyPackages = skipEmptyPackages, reportUndocumented = reportNotDocumented, impliedPlatforms = impliedPlatforms, - perPackageOptions = perPackageOptions + perPackageOptions = perPackageOptions, + externalDocumentationLinks = externalDocumentationLinks.map { it.build() } ) ) |