aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-05-11 16:31:04 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-05-11 19:54:45 +0300
commit0e8733ead6d5c4c6db7e4fe8a1f34b7598823290 (patch)
treec3229a24b1dcab6b0a66dfe65283c041936719b1
parenta86c859eba6154524f3b42461aad6b45f26e3650 (diff)
downloaddokka-0e8733ead6d5c4c6db7e4fe8a1f34b7598823290.tar.gz
dokka-0e8733ead6d5c4c6db7e4fe8a1f34b7598823290.tar.bz2
dokka-0e8733ead6d5c4c6db7e4fe8a1f34b7598823290.zip
Add external documentation links argument to gradle, maven, ant
-rw-r--r--core/src/main/kotlin/Generation/configurationImpl.kt14
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt2
-rw-r--r--integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt22
-rw-r--r--runners/ant/src/main/kotlin/ant/dokka.kt8
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt7
-rw-r--r--runners/gradle-plugin/src/main/kotlin/main.kt12
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt15
7 files changed, 60 insertions, 20 deletions
diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt
index 425b016b..b51857e7 100644
--- a/core/src/main/kotlin/Generation/configurationImpl.kt
+++ b/core/src/main/kotlin/Generation/configurationImpl.kt
@@ -3,7 +3,6 @@ package org.jetbrains.dokka
import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition
import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
import java.io.File
-import java.net.URL
data class SourceLinkDefinitionImpl(override val path: String,
@@ -35,16 +34,6 @@ data class PackageOptionsImpl(override val prefix: String,
override val reportUndocumented: Boolean = true,
override val skipDeprecated: Boolean = false) : DokkaConfiguration.PackageOptions
-data class ExternalDocumentationLinkImpl(override val url: URL,
- override val packageListUrl: URL) : DokkaConfiguration.ExternalDocumentationLink {
- constructor(root: URL) : this(root, URL(root, "package-list"))
-
- constructor(root: String) : this(URL(root))
-
- constructor(root: String, packageListUrl: String) : this(URL(root), URL(packageListUrl))
-
-}
-
data class DokkaConfigurationImpl(override val moduleName: String,
override val classpath: List<String>,
override val sourceRoots: List<SourceRootImpl>,
@@ -61,4 +50,5 @@ data class DokkaConfigurationImpl(override val moduleName: String,
override val generateIndexPages: Boolean,
override val sourceLinks: List<SourceLinkDefinitionImpl>,
override val impliedPlatforms: List<String>,
- override val perPackageOptions: List<PackageOptionsImpl>) : DokkaConfiguration \ No newline at end of file
+ override val perPackageOptions: List<PackageOptionsImpl>,
+ override val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>) : DokkaConfiguration \ No newline at end of file
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 6a18bf26..5049f42d 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -56,7 +56,7 @@ class DocumentationOptions(val outputDir: String,
fun effectivePackageOptions(pack: String): PackageOptions = perPackageOptions.firstOrNull { pack.startsWith(it.prefix + ".") } ?: rootPackageOptions
fun effectivePackageOptions(pack: FqName): PackageOptions = effectivePackageOptions(pack.asString())
- val externalDocumentationLinks = listOf(ExternalDocumentationLinkImpl("http://docs.oracle.com/javase/$jdkVersion/docs/api/")) + externalDocumentationLinks
+ val externalDocumentationLinks = listOf(ExternalDocumentationLink.Builder("http://docs.oracle.com/javase/$jdkVersion/docs/api/").build()) + externalDocumentationLinks
}
private fun isExtensionForExternalClass(extensionFunctionDescriptor: DeclarationDescriptor,
diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
index 7f16b1a5..ca6f0bc4 100644
--- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
+++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
@@ -21,6 +21,7 @@ interface DokkaConfiguration {
val sourceLinks: List<SourceLinkDefinition>
val impliedPlatforms: List<String>
val perPackageOptions: List<PackageOptions>
+ val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink>
interface SourceRoot {
val path: String
@@ -43,6 +44,20 @@ interface DokkaConfiguration {
interface ExternalDocumentationLink {
val url: URL
val packageListUrl: URL
+
+ open class Builder(open var url: URL? = null,
+ open var packageListUrl: URL? = null) {
+
+ constructor(root: String) : this(URL(root), null)
+
+ fun build(): DokkaConfiguration.ExternalDocumentationLink =
+ if (packageListUrl != null && url != null)
+ ExternalDocumentationLinkImpl(url!!, packageListUrl!!)
+ else if (url != null)
+ ExternalDocumentationLinkImpl(url!!, URL(url!!, "package-list"))
+ else
+ throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link")
+ }
}
}
@@ -62,4 +77,9 @@ data class SerializeOnlyDokkaConfiguration(override val moduleName: String,
override val generateIndexPages: Boolean,
override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition>,
override val impliedPlatforms: List<String>,
- override val perPackageOptions: List<DokkaConfiguration.PackageOptions>) : DokkaConfiguration
+ override val perPackageOptions: List<DokkaConfiguration.PackageOptions>,
+ override val externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink>) : DokkaConfiguration
+
+
+data class ExternalDocumentationLinkImpl internal constructor(override val url: URL,
+ override val packageListUrl: URL) : DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file
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() }
)
)