aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt7
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt4
-rw-r--r--core/src/main/kotlin/Generation/configurationImpl.kt11
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt19
-rw-r--r--integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt15
-rw-r--r--runners/ant/src/main/kotlin/ant/dokka.kt17
-rw-r--r--runners/gradle-plugin/src/main/kotlin/main.kt23
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt49
8 files changed, 107 insertions, 38 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
index fafa5daaa..5ac1c57f0 100644
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka
+import org.jetbrains.dokka.DokkaConfiguration.PackageOptions
import ru.yole.jkid.deserialization.deserialize
import java.util.function.BiConsumer
@@ -15,7 +16,7 @@ fun parsePerPackageOptions(arg: String): List<PackageOptions> {
val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true
val reportUndocumented = args.find { it.endsWith("warnUndocumented") }?.startsWith("+") ?: true
val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false
- PackageOptions(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated)
+ PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated)
}
}
@@ -58,7 +59,9 @@ class DokkaBootstrapImpl : DokkaBootstrap {
skipDeprecated,
jdkVersion,
generateIndexPages,
- sourceLinks
+ sourceLinks,
+ impliedPlatforms,
+ perPackageOptions
)
)
}
diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index 67c641a04..3350ab1d5 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -35,7 +35,7 @@ class DokkaGenerator(val logger: DokkaLogger,
private val documentationModule = DocumentationModule(moduleName)
fun generate() {
- val sourcesGroupedByPlatform = sources.groupBy { it.defaultPlatforms.firstOrNull() }
+ val sourcesGroupedByPlatform = sources.groupBy { it.platforms.firstOrNull() }
for ((platform, roots) in sourcesGroupedByPlatform) {
appendSourceModule(platform, roots)
}
@@ -67,7 +67,7 @@ class DokkaGenerator(val logger: DokkaLogger,
val containingFilePath = descriptor.sourcePsi()?.containingFile?.virtualFile?.canonicalPath
?.let { File(it).absolutePath }
val sourceRoot = containingFilePath?.let { path -> sourceRoots.find { path.startsWith(it.path) } }
- return sourceRoot?.defaultPlatforms ?: defaultPlatformAsList
+ return sourceRoot?.platforms ?: defaultPlatformAsList
}
}
diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt
index 6ed0d6390..bb2f6d12f 100644
--- a/core/src/main/kotlin/Generation/configurationImpl.kt
+++ b/core/src/main/kotlin/Generation/configurationImpl.kt
@@ -18,7 +18,7 @@ data class SourceLinkDefinitionImpl(override val path: String,
}
}
-class SourceRootImpl(path: String, override val defaultPlatforms: List<String> = emptyList()) : SourceRoot {
+class SourceRootImpl(path: String, override val platforms: List<String> = emptyList()) : SourceRoot {
override val path: String = File(path).absolutePath
companion object {
@@ -29,6 +29,11 @@ class SourceRootImpl(path: String, override val defaultPlatforms: List<String> =
}
}
+data class PackageOptionsImpl(override val prefix: String,
+ override val includeNonPublic: Boolean = false,
+ override val reportUndocumented: Boolean = true,
+ override val skipDeprecated: Boolean = false) : DokkaConfiguration.PackageOptions
+
data class DokkaConfigurationImpl(override val moduleName: String,
override val classpath: List<String>,
override val sourceRoots: List<SourceRootImpl>,
@@ -43,4 +48,6 @@ data class DokkaConfigurationImpl(override val moduleName: String,
override val skipDeprecated: Boolean,
override val jdkVersion: Int,
override val generateIndexPages: Boolean,
- override val sourceLinks: List<SourceLinkDefinitionImpl>) : DokkaConfiguration \ No newline at end of file
+ override val sourceLinks: List<SourceLinkDefinitionImpl>,
+ override val impliedPlatforms: List<String>,
+ override val perPackageOptions: List<PackageOptionsImpl>) : 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 aa4eed24f..b034a299e 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiJavaFile
+import org.jetbrains.dokka.DokkaConfiguration.PackageOptions
import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition
import org.jetbrains.dokka.Kotlin.DescriptorDocumentationParser
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
@@ -44,21 +45,19 @@ class DocumentationOptions(val outputDir: String,
val impliedPlatforms: List<String> = emptyList(),
// Sorted by pattern length
perPackageOptions: List<PackageOptions> = emptyList()) {
- val perPackageOptions = perPackageOptions.sortedByDescending { it.prefix.length } + PackageOptions("", includeNonPublic, reportUndocumented, skipDeprecated)
+ init {
+ if (perPackageOptions.any { it.prefix == "" })
+ throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead")
+ }
+
+ val perPackageOptions = perPackageOptions.sortedByDescending { it.prefix.length }
+ val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated)
- fun effectivePackageOptions(pack: String): PackageOptions = perPackageOptions.first { pack.startsWith(it.prefix) }
+ fun effectivePackageOptions(pack: String): PackageOptions = perPackageOptions.firstOrNull { pack.startsWith(it.prefix + ".") } ?: rootPackageOptions
fun effectivePackageOptions(pack: FqName): PackageOptions = effectivePackageOptions(pack.asString())
}
-
-data class PackageOptions(val prefix: String,
- val includeNonPublic: Boolean = false,
- val reportUndocumented: Boolean = true,
- val skipDeprecated: Boolean = false)
-
-
-
private fun isExtensionForExternalClass(extensionFunctionDescriptor: DeclarationDescriptor,
extensionReceiverDescriptor: DeclarationDescriptor,
allFqNames: Collection<FqName>): Boolean {
diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
index 90ba41ced..5d10f6d21 100644
--- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
+++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
@@ -17,10 +17,12 @@ interface DokkaConfiguration {
val jdkVersion: Int
val generateIndexPages: Boolean
val sourceLinks: List<SourceLinkDefinition>
+ val impliedPlatforms: List<String>
+ val perPackageOptions: List<PackageOptions>
interface SourceRoot {
val path: String
- val defaultPlatforms: List<String>
+ val platforms: List<String>
}
interface SourceLinkDefinition {
@@ -28,6 +30,13 @@ interface DokkaConfiguration {
val url: String
val lineSuffix: String?
}
+
+ interface PackageOptions {
+ val prefix: String
+ val includeNonPublic: Boolean
+ val reportUndocumented: Boolean
+ val skipDeprecated: Boolean
+ }
}
data class SerializeOnlyDokkaConfiguration(override val moduleName: String,
@@ -44,4 +53,6 @@ data class SerializeOnlyDokkaConfiguration(override val moduleName: String,
override val skipDeprecated: Boolean,
override val jdkVersion: Int,
override val generateIndexPages: Boolean,
- override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition>) : DokkaConfiguration
+ override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition>,
+ override val impliedPlatforms: List<String>,
+ override val perPackageOptions: List<DokkaConfiguration.PackageOptions>) : DokkaConfiguration
diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt
index 546948802..f645aea4b 100644
--- a/runners/ant/src/main/kotlin/ant/dokka.kt
+++ b/runners/ant/src/main/kotlin/ant/dokka.kt
@@ -23,16 +23,11 @@ class AntSourceRoot(var path: String? = null, var platforms: String? = null) {
}
}
-class AntPackageOptions(var prefix: String = "",
- var includeNonPublic: Boolean = false,
- var reportUndocumented: Boolean = true,
- var skipDeprecated: Boolean = false) {
- fun toPackageOptions(): PackageOptions {
- if(prefix == "")
- throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead")
- return PackageOptions(prefix, includeNonPublic, reportUndocumented, skipDeprecated)
- }
-}
+class AntPackageOptions(
+ override var prefix: String = "",
+ override var includeNonPublic: Boolean = false,
+ override var reportUndocumented: Boolean = true,
+ override var skipDeprecated: Boolean = false) : DokkaConfiguration.PackageOptions
class DokkaAntTask: Task() {
@@ -119,7 +114,7 @@ class DokkaAntTask: Task() {
sourceLinks = sourceLinks,
jdkVersion = jdkVersion,
impliedPlatforms = impliedPlatforms.split(','),
- perPackageOptions = antPackageOptions.map { it.toPackageOptions() })
+ perPackageOptions = antPackageOptions)
)
generator.generate()
}
diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt
index 7aa871adb..60311fffd 100644
--- a/runners/gradle-plugin/src/main/kotlin/main.kt
+++ b/runners/gradle-plugin/src/main/kotlin/main.kt
@@ -82,6 +82,8 @@ open class DokkaTask : DefaultTask() {
@Input var skipDeprecated = false
@Input var skipEmptyPackages = true
@Input var reportNotDocumented = true
+ @Input var perPackageOptions: MutableList<PackageOptions> = arrayListOf()
+ @Input var impliedPlatforms: MutableList<String> = arrayListOf()
protected open val sdkProvider: SdkProvider? = null
@@ -108,6 +110,13 @@ open class DokkaTask : DefaultTask() {
sourceRoots.add(sourceRoot)
}
+ fun packageOptions(closure: Closure<Any?>) {
+ val packageOptions = PackageOptions()
+ closure.delegate = packageOptions
+ closure.call()
+ perPackageOptions.add(packageOptions)
+ }
+
fun tryResolveFatJar(project: Project): File {
return try {
val dependency = project.buildscript.dependencies.create(dokkaFatJar)
@@ -172,9 +181,11 @@ open class DokkaTask : DefaultTask() {
reportNotDocumented,
skipEmptyPackages,
skipDeprecated,
- 6,
+ jdkVersion,
true,
- linkMappings)
+ linkMappings,
+ impliedPlatforms,
+ perPackageOptions)
bootstrapProxy.configure(
@@ -238,7 +249,7 @@ class SourceRoot : DokkaConfiguration.SourceRoot {
field = File(value).absolutePath
}
- override var defaultPlatforms: List<String> = arrayListOf()
+ override var platforms: List<String> = arrayListOf()
}
open class LinkMapping : Serializable, DokkaConfiguration.SourceLinkDefinition {
@@ -286,6 +297,12 @@ open class LinkMapping : Serializable, DokkaConfiguration.SourceLinkDefinition {
}
}
+class PackageOptions : DokkaConfiguration.PackageOptions {
+ override var prefix: String = ""
+ override var includeNonPublic: Boolean = false
+ override var reportUndocumented: Boolean = true
+ override var skipDeprecated: Boolean = false
+}
/**
* A provider for SDKs that can be used if a project uses classes that live outside the JDK or uses a
* different method to determine the source directories.
diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
index dcccdb1fb..dbae23628 100644
--- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
+++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
@@ -9,10 +9,7 @@ import org.apache.maven.project.MavenProject
import org.apache.maven.project.MavenProjectHelper
import org.codehaus.plexus.archiver.Archiver
import org.codehaus.plexus.archiver.jar.JarArchiver
-import org.jetbrains.dokka.DocumentationOptions
-import org.jetbrains.dokka.DokkaGenerator
-import org.jetbrains.dokka.SourceLinkDefinitionImpl
-import org.jetbrains.dokka.SourceRootImpl
+import org.jetbrains.dokka.*
import java.io.File
class SourceLinkMapItem {
@@ -27,10 +24,32 @@ class SourceLinkMapItem {
}
abstract class AbstractDokkaMojo : AbstractMojo() {
+ class SourceRoot : DokkaConfiguration.SourceRoot {
+ @Parameter(required = true)
+ override var path: String = ""
+
+ @Parameter
+ override var platforms: List<String> = emptyList()
+ }
+
+ class PackageOptions : DokkaConfiguration.PackageOptions {
+ @Parameter
+ override var prefix: String = ""
+ @Parameter
+ override var includeNonPublic: Boolean = false
+ @Parameter
+ override var reportUndocumented: Boolean = true
+ @Parameter
+ override var skipDeprecated: Boolean = false
+ }
+
@Parameter(required = true, defaultValue = "\${project.compileSourceRoots}")
var sourceDirectories: List<String> = emptyList()
@Parameter
+ var sourceRoots: List<SourceRoot> = emptyList()
+
+ @Parameter
var samplesDirs: List<String> = emptyList()
@Parameter
@@ -55,6 +74,19 @@ abstract class AbstractDokkaMojo : AbstractMojo() {
@Parameter(required = false, defaultValue = "6")
var jdkVersion: Int = 6
+ @Parameter
+ var skipDeprecated = false
+ @Parameter
+ var skipEmptyPackages = true
+ @Parameter
+ var reportNotDocumented = true
+
+ @Parameter
+ var impliedPlatforms: List<String> = emptyList()
+
+ @Parameter
+ var perPackageOptions: List<PackageOptions> = emptyList()
+
protected abstract fun getOutDir(): String
protected abstract fun getOutFormat(): String
@@ -67,13 +99,18 @@ abstract class AbstractDokkaMojo : AbstractMojo() {
val gen = DokkaGenerator(
MavenDokkaLogger(log),
classpath,
- sourceDirectories.map { SourceRootImpl(it) },
+ sourceDirectories.map { SourceRootImpl(it) } + sourceRoots,
samplesDirs,
includeDirs + includes,
moduleName,
DocumentationOptions(getOutDir(), getOutFormat(),
sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.dir, it.url, it.urlSuffix) },
- jdkVersion = jdkVersion
+ jdkVersion = jdkVersion,
+ skipDeprecated = skipDeprecated,
+ skipEmptyPackages = skipEmptyPackages,
+ reportUndocumented = reportNotDocumented,
+ impliedPlatforms = impliedPlatforms,
+ perPackageOptions = perPackageOptions
)
)