aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle1
-rw-r--r--core/build.gradle4
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt37
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt5
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt2
-rw-r--r--core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt2
-rw-r--r--core/src/main/kotlin/Utilities/ServiceLocator.kt2
-rw-r--r--core/src/test/kotlin/DokkaConfigurationTestImplementations.kt (renamed from core/src/main/kotlin/Generation/configurationImpl.kt)41
-rw-r--r--gradle.properties3
-rw-r--r--integration/build.gradle13
-rw-r--r--integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt53
-rw-r--r--integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt79
-rw-r--r--runners/android-gradle-plugin/build.gradle4
-rw-r--r--runners/ant/build.gradle4
-rw-r--r--runners/cli/build.gradle4
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt33
-rw-r--r--runners/gradle-integration-tests/build.gradle4
-rw-r--r--runners/gradle-plugin/build.gradle4
-rw-r--r--runners/gradle-plugin/src/main/kotlin/main.kt137
-rw-r--r--runners/maven-plugin/build.gradle4
20 files changed, 262 insertions, 174 deletions
diff --git a/build.gradle b/build.gradle
index 3a8b555e..19a97b4d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -45,6 +45,7 @@ allprojects {
maven { url 'https://jitpack.io' }
maven { url "https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/$bundled_kotlin_compiler_version/maven" }
ivy(repo)
+ maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://dl.bintray.com/kotlin/kotlinx" }
maven { url "https://dl.bintray.com/orangy/maven" } // TODO: remove this repository when kotlinx.cli is available in maven
}
diff --git a/core/build.gradle b/core/build.gradle
index c90a7789..0008bfd7 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -12,8 +12,8 @@ sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
- languageVersion = "1.2"
- apiVersion = languageVersion
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
index ccafcd12..2077458a 100644
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt
@@ -1,7 +1,10 @@
package org.jetbrains.dokka
+import com.intellij.openapi.util.Pass
+import kotlinx.serialization.*
+import kotlinx.serialization.json.Json
import org.jetbrains.dokka.DokkaConfiguration.PackageOptions
-import ru.yole.jkid.deserialization.deserialize
+
import java.util.function.BiConsumer
@@ -40,11 +43,35 @@ class DokkaBootstrapImpl : DokkaBootstrap {
lateinit var generator: DokkaGenerator
override fun configure(logger: BiConsumer<String, String>, serializedConfigurationJSON: String)
- = configure(DokkaProxyLogger(logger), deserialize<DokkaConfigurationImpl>(serializedConfigurationJSON))
+ = configure(DokkaProxyLogger(logger), Json.parse(DokkaConfigurationImpl.serializer(), serializedConfigurationJSON))
+
+ fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) = with(configuration) {
- fun configure(logger: DokkaLogger, configuration: DokkaConfiguration) = with(configuration) {
- generator = DokkaGenerator(configuration, logger)
+ fun defaultLinks(config: PassConfigurationImpl): List<ExternalDocumentationLinkImpl> {
+ val links = mutableListOf<ExternalDocumentationLinkImpl>()
+ if (!config.noJdkLink)
+ links += DokkaConfiguration.ExternalDocumentationLink
+ .Builder("https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/")
+ .build() as ExternalDocumentationLinkImpl
+
+ if (!config.noStdlibLink)
+ links += DokkaConfiguration.ExternalDocumentationLink
+ .Builder("https://kotlinlang.org/api/latest/jvm/stdlib/")
+ .build() as ExternalDocumentationLinkImpl
+ return links
+ }
+
+ val configurationWithLinks =
+ configuration.copy(passesConfigurations =
+ passesConfigurations
+ .map {
+ val links: List<ExternalDocumentationLinkImpl> = it.externalDocumentationLinks + defaultLinks(it)
+ it.copy(externalDocumentationLinks = links)
+ }
+ )
+
+ generator = DokkaGenerator(configurationWithLinks, logger)
}
override fun generate() = generator.generate()
-} \ No newline at end of file
+}
diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt
index 70af73f9..66db46d7 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -234,9 +234,8 @@ class JavadocParser(
linkSignature != null -> {
val linkNode =
ContentNodeLazyLink(
- (tag.valueElement ?: linkElement).text,
- { -> refGraph.lookupOrWarn(linkSignature, logger) }
- )
+ (tag.valueElement ?: linkElement).text
+ ) { -> refGraph.lookupOrWarn(linkSignature!!, logger) }
linkNode.append(text)
linkNode
}
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index e3f7c35b..d6413b64 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -1156,7 +1156,7 @@ fun ClassDescriptor.supertypesWithAnyPrecise(): Collection<KotlinType> {
}
fun PassConfiguration.effectivePackageOptions(pack: String): DokkaConfiguration.PackageOptions {
- val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated)
+ val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated, false)
return perPackageOptions.firstOrNull { pack == it.prefix || pack.startsWith(it.prefix + ".") } ?: rootPackageOptions
}
diff --git a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
index 9d986aee..793f9589 100644
--- a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
@@ -154,7 +154,7 @@ class PackageListProvider @Inject constructor(
.toMap()
- val defaultResolverDesc = ExternalDocumentationLinkResolver.services["dokka-default"]!!
+ val defaultResolverDesc = ExternalDocumentationLinkResolver.services.getValue("dokka-default")
val resolverDesc = ExternalDocumentationLinkResolver.services[format]
?: defaultResolverDesc.takeIf { format in formatsWithDefaultResolver }
?: defaultResolverDesc.also {
diff --git a/core/src/main/kotlin/Utilities/ServiceLocator.kt b/core/src/main/kotlin/Utilities/ServiceLocator.kt
index fca08f38..b2743c53 100644
--- a/core/src/main/kotlin/Utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/Utilities/ServiceLocator.kt
@@ -70,7 +70,7 @@ object ServiceLocator {
"jar" -> {
val file = JarFile(URL(it.file.substringBefore("!")).toFile())
try {
- val jarPath = it.file.substringAfterLast("!").removeSurrounding("/")
+ val jarPath = it.file.substringAfterLast("!").removePrefix("/") // TODO: revision b265a9ffacb8f8e8e6226a9458a92697b02355a8 - removeSurrounding for Ant breaks Gradle
file.entries()
.asSequence()
.filter { entry -> !entry.isDirectory && entry.path == jarPath && entry.extension == "properties" }
diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/test/kotlin/DokkaConfigurationTestImplementations.kt
index 46174198..19ec1e64 100644
--- a/core/src/main/kotlin/Generation/configurationImpl.kt
+++ b/core/src/test/kotlin/DokkaConfigurationTestImplementations.kt
@@ -1,28 +1,29 @@
-package org.jetbrains.dokka
+package org.jetbrains.dokka.tests
-import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition
-import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.Platform
import java.io.File
data class SourceLinkDefinitionImpl(override val path: String,
override val url: String,
- override val lineSuffix: String?) : SourceLinkDefinition {
+ override val lineSuffix: String?) : DokkaConfiguration.SourceLinkDefinition {
companion object {
- fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition {
+ fun parseSourceLinkDefinition(srcLink: String): DokkaConfiguration.SourceLinkDefinition {
val (path, urlAndLine) = srcLink.split('=')
- return SourceLinkDefinitionImpl(File(path).canonicalPath,
+ return SourceLinkDefinitionImpl(
+ File(path).canonicalPath,
urlAndLine.substringBefore("#"),
urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" })
}
}
}
-class SourceRootImpl(path: String) : SourceRoot {
+class SourceRootImpl(path: String) : DokkaConfiguration.SourceRoot {
override val path: String = File(path).absolutePath
companion object {
- fun parseSourceRoot(sourceRoot: String): SourceRoot = SourceRootImpl(sourceRoot)
+ fun parseSourceRoot(sourceRoot: String): DokkaConfiguration.SourceRoot = SourceRootImpl(sourceRoot)
}
}
@@ -32,38 +33,38 @@ data class PackageOptionsImpl(override val prefix: String,
override val skipDeprecated: Boolean = false,
override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions
-data class DokkaConfigurationImpl(
+ class DokkaConfigurationImpl(
override val outputDir: String = "",
override val format: String = "html",
override val generateIndexPages: Boolean = false,
override val cacheRoot: String? = null,
- override val impliedPlatforms: List<String> = listOf(),
- override val passesConfigurations: List<DokkaConfiguration.PassConfiguration> = listOf()
+ override val impliedPlatforms: List<String> = emptyList(),
+ override val passesConfigurations: List<DokkaConfiguration.PassConfiguration> = emptyList()
) : DokkaConfiguration
class PassConfigurationImpl (
- override val classpath: List<String> = listOf(),
+ override val classpath: List<String> = emptyList(),
override val moduleName: String = "",
- override val sourceRoots: List<SourceRoot> = listOf(),
- override val samples: List<String> = listOf(),
- override val includes: List<String> = listOf(),
+ override val sourceRoots: List<DokkaConfiguration.SourceRoot> = emptyList(),
+ override val samples: List<String> = emptyList(),
+ override val includes: List<String> = emptyList(),
override val includeNonPublic: Boolean = false,
override val includeRootPackage: Boolean = false,
override val reportUndocumented: Boolean = false,
override val skipEmptyPackages: Boolean = false,
override val skipDeprecated: Boolean = false,
override val jdkVersion: Int = 6,
- override val sourceLinks: List<SourceLinkDefinition> = listOf(),
- override val perPackageOptions: List<DokkaConfiguration.PackageOptions> = listOf(),
- externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> = listOf(),
+ override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition> = emptyList(),
+ override val perPackageOptions: List<DokkaConfiguration.PackageOptions> = emptyList(),
+ externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> = emptyList(),
override val languageVersion: String? = null,
override val apiVersion: String? = null,
override val noStdlibLink: Boolean = false,
override val noJdkLink: Boolean = false,
- override val suppressedFiles: List<String> = listOf(),
+ override val suppressedFiles: List<String> = emptyList(),
override val collectInheritedExtensionsFromLibraries: Boolean = false,
override val analysisPlatform: Platform = Platform.DEFAULT,
- override val targets: List<String> = listOf(),
+ override val targets: List<String> = emptyList(),
override val sinceKotlin: String = "1.0"
): DokkaConfiguration.PassConfiguration {
private val defaultLinks = run {
diff --git a/gradle.properties b/gradle.properties
index ab4a0920..f38548d2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,8 +3,9 @@ dokka_publication_channel=dokka
#Kotlin compiler and plugin
bundled_kotlin_compiler_version=1.3.20-dev-564
-kotlin_version=1.2.61
+kotlin_version=1.3.21
kotlin_for_gradle_runtime_version=1.1.60
+language_version=1.3
ant_version=1.9.6
diff --git a/integration/build.gradle b/integration/build.gradle
index 24d59edf..ce95844c 100644
--- a/integration/build.gradle
+++ b/integration/build.gradle
@@ -1,18 +1,21 @@
buildscript {
+ repositories { jcenter() }
+
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
apply plugin: 'kotlin'
-
+apply plugin: 'kotlinx-serialization'
sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
- languageVersion = "1.2"
- apiVersion = "1.1"
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}
@@ -20,7 +23,5 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
dependencies {
compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version
compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version
- compile('com.github.yole:jkid:8fc7f12e1a') {
- transitive = false
- }
+ compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0"
} \ No newline at end of file
diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
index 12efd252..717fa477 100644
--- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
+++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt
@@ -1,22 +1,26 @@
package org.jetbrains.dokka
-import ru.yole.jkid.CustomSerializer
-import ru.yole.jkid.ValueSerializer
-import ru.yole.jkid.deserialization.JKidException
-import java.io.Serializable
+import kotlinx.serialization.*
+import kotlinx.serialization.internal.StringDescriptor
import java.net.URL
-class UrlSerializer : ValueSerializer<URL?> {
- override fun fromJsonValue(jsonValue: Any?): URL? {
- if (jsonValue !is String?)
- throw JKidException("Expected string representation of URL, got: $jsonValue")
- return jsonValue?.let { URL(jsonValue) }
+@Serializer(forClass = URL::class)
+object UrlSerializer: KSerializer<URL> {
+
+ override val descriptor: SerialDescriptor =
+ StringDescriptor.withName("WithCustomDefault")
+
+ override fun deserialize(decoder: Decoder): URL {
+ return URL(decoder.decodeString())
}
- override fun toJsonValue(value: URL?): Any? = value?.toExternalForm()
+ override fun serialize(encoder: Encoder, obj: URL) {
+ encoder.encodeString(obj.toExternalForm())
+ }
}
+
enum class Platform(val key: String) {
jvm("jvm"),
js("js"),
@@ -93,8 +97,8 @@ interface DokkaConfiguration {
}
interface ExternalDocumentationLink {
- @CustomSerializer(UrlSerializer::class) val url: URL
- @CustomSerializer(UrlSerializer::class) val packageListUrl: URL
+ @Serializable(with = UrlSerializer::class) val url: URL
+ @Serializable(with = UrlSerializer::class) val packageListUrl: URL
open class Builder(open var url: URL? = null,
open var packageListUrl: URL? = null) {
@@ -102,25 +106,12 @@ interface DokkaConfiguration {
constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) })
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")
+ 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")
}
}
}
-
-data class SerializeOnlyDokkaConfiguration(
- override val outputDir: String,
- override val format: String,
- override val generateIndexPages: Boolean,
- override val cacheRoot: String?,
- override val impliedPlatforms: List<String>,
- override val passesConfigurations: List<DokkaConfiguration.PassConfiguration>
-) : DokkaConfiguration
-
-
-data class ExternalDocumentationLinkImpl(@CustomSerializer(UrlSerializer::class) override val url: URL,
- @CustomSerializer(UrlSerializer::class) override val packageListUrl: URL) : Serializable, DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file
diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt
new file mode 100644
index 00000000..615f0215
--- /dev/null
+++ b/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt
@@ -0,0 +1,79 @@
+package org.jetbrains.dokka
+
+import kotlinx.serialization.Serializable
+import java.io.File
+import java.net.URL
+
+@Serializable
+data class DokkaConfigurationImpl(
+ override val outputDir: String,
+ override val format: String,
+ override val generateIndexPages: Boolean,
+ override val cacheRoot: String?,
+ override val impliedPlatforms: List<String>,
+ override val passesConfigurations: List<PassConfigurationImpl>
+) : DokkaConfiguration
+
+@Serializable
+data class PassConfigurationImpl (
+ override val moduleName: String,
+ override val classpath: List<String>,
+ override val sourceRoots: List<SourceRootImpl>,
+ override val samples: List<String>,
+ override val includes: List<String>,
+ override val includeNonPublic: Boolean,
+ override val includeRootPackage: Boolean,
+ override val reportUndocumented: Boolean,
+ override val skipEmptyPackages: Boolean,
+ override val skipDeprecated: Boolean,
+ override val jdkVersion: Int,
+ override val sourceLinks: List<SourceLinkDefinitionImpl>,
+ override val perPackageOptions: List<PackageOptionsImpl>,
+ override var externalDocumentationLinks: List<ExternalDocumentationLinkImpl>,
+ override val languageVersion: String?,
+ override val apiVersion: String?,
+ override val noStdlibLink: Boolean,
+ override val noJdkLink: Boolean,
+ override val suppressedFiles: List<String>,
+ override val collectInheritedExtensionsFromLibraries: Boolean,
+ override val analysisPlatform: Platform,
+ override val targets: List<String>,
+ override val sinceKotlin: String
+) : DokkaConfiguration.PassConfiguration
+
+@Serializable
+data class SourceRootImpl(
+ override val path: String
+): DokkaConfiguration.SourceRoot
+
+@Serializable
+data class SourceLinkDefinitionImpl(
+ override val path: String,
+ override val url: String,
+ override val lineSuffix: String?
+): DokkaConfiguration.SourceLinkDefinition {
+ companion object {
+ fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl {
+ val (path, urlAndLine) = srcLink.split('=')
+ return SourceLinkDefinitionImpl(
+ File(path).canonicalPath,
+ urlAndLine.substringBefore("#"),
+ urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" })
+ }
+ }
+}
+
+@Serializable
+data class PackageOptionsImpl(
+ override val prefix: String,
+ override val includeNonPublic: Boolean,
+ override val reportUndocumented: Boolean,
+ override val skipDeprecated: Boolean,
+ override val suppress: Boolean
+): DokkaConfiguration.PackageOptions
+
+
+@Serializable
+data class ExternalDocumentationLinkImpl(@Serializable(with = UrlSerializer::class) override val url: URL,
+ @Serializable(with = UrlSerializer::class) override val packageListUrl: URL
+) : DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file
diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle
index 28b0cbb9..6126510b 100644
--- a/runners/android-gradle-plugin/build.gradle
+++ b/runners/android-gradle-plugin/build.gradle
@@ -13,8 +13,8 @@ sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
- languageVersion = "1.2"
- apiVersion = "1.1"
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}
diff --git a/runners/ant/build.gradle b/runners/ant/build.gradle
index e7dcd441..216420c6 100644
--- a/runners/ant/build.gradle
+++ b/runners/ant/build.gradle
@@ -5,8 +5,8 @@ sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
- languageVersion = "1.2"
- apiVersion = languageVersion
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}
diff --git a/runners/cli/build.gradle b/runners/cli/build.gradle
index 8b1c03a8..24db0b1e 100644
--- a/runners/cli/build.gradle
+++ b/runners/cli/build.gradle
@@ -4,8 +4,8 @@ sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
- languageVersion = "1.2"
- apiVersion = languageVersion
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
index d67a9875..9e42d01a 100644
--- a/runners/cli/src/main/kotlin/cli/main.kt
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -1,9 +1,6 @@
package org.jetbrains.dokka
-import kotlinx.cli.registerAction
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
-import org.jetbrains.kotlin.daemon.common.compareDaemonJVMOptionsMemory
-
import java.io.File
import java.net.MalformedURLException
import java.net.URL
@@ -57,7 +54,7 @@ class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfi
override val sourceRoots: List<DokkaConfiguration.SourceRoot> by parser.repeatableOption(
listOf("-src"),
"Source file or directory (allows many paths separated by the system path separator)"
- ) { SourceRootImpl.parseSourceRoot(it) }
+ ) { SourceRootImpl(it) }
override val samples: List<String> by parser.repeatableOption(
listOf("-samples"),
@@ -121,9 +118,9 @@ class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfi
)
override val sinceKotlin: String by parser.stringOption(
- listOf("-sinceKotlin"),
- "Kotlin Api version to use as base version, if none specified",
- "1.0"
+ listOf("-sinceKotlin"),
+ "Kotlin Api version to use as base version, if none specified",
+ "1.0"
)
override val collectInheritedExtensionsFromLibraries: Boolean by parser.singleFlag(
@@ -154,19 +151,19 @@ class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfi
object MainKt {
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 }
+ .map { it.split("^").map { it.trim() }.filter { it.isNotBlank() } }
+ .filter { it.isNotEmpty() }
+ .partition { it.size == 1 }
return parsedLinks.map { (root) -> ExternalDocumentationLink.Builder(root).build() } +
parsedOfflineLinks.map { (root, packageList) ->
val rootUrl = URL(root)
val packageListUrl =
- try {
- URL(packageList)
- } catch (ex: MalformedURLException) {
- File(packageList).toURI().toURL()
- }
+ try {
+ URL(packageList)
+ } catch (ex: MalformedURLException) {
+ File(packageList).toURI().toURL()
+ }
ExternalDocumentationLink.Builder(rootUrl, packageListUrl).build()
}
}
@@ -206,8 +203,8 @@ object MainKt {
} catch (e: ClassNotFoundException) {
val classLoader = createClassLoaderWithTools()
classLoader.loadClass("org.jetbrains.dokka.MainKt")
- .methods.find { it.name == "entry" }!!
- .invoke(null, configuration)
+ .methods.find { it.name == "entry" }!!
+ .invoke(null, configuration)
}
}
@@ -220,7 +217,7 @@ object MainKt {
parseContext.cli.singleAction(
- listOf("-pckageOptions"),
+ listOf("-pckageOptions"),
"List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" "
) {
configuration.passesConfigurations.last().perPackageOptions.addAll(parsePerPackageOptions(it))
diff --git a/runners/gradle-integration-tests/build.gradle b/runners/gradle-integration-tests/build.gradle
index 297a175a..2f08bdb8 100644
--- a/runners/gradle-integration-tests/build.gradle
+++ b/runners/gradle-integration-tests/build.gradle
@@ -7,8 +7,8 @@ sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
- languageVersion = "1.2"
- apiVersion = "1.0"
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}
diff --git a/runners/gradle-plugin/build.gradle b/runners/gradle-plugin/build.gradle
index 8e59a7be..1c307588 100644
--- a/runners/gradle-plugin/build.gradle
+++ b/runners/gradle-plugin/build.gradle
@@ -12,8 +12,8 @@ sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
- languageVersion = "1.2"
- apiVersion = "1.1"
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}
diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt
index f726c6c7..ef7bd41f 100644
--- a/runners/gradle-plugin/src/main/kotlin/main.kt
+++ b/runners/gradle-plugin/src/main/kotlin/main.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka.gradle
import groovy.lang.Closure
+import kotlinx.serialization.*
+import kotlinx.serialization.json.Json
import org.gradle.api.Action
import org.gradle.api.DefaultTask
import org.gradle.api.Plugin
@@ -17,8 +19,7 @@ import org.jetbrains.dokka.*
import org.jetbrains.dokka.ReflectDsl.isNotInstance
import org.jetbrains.dokka.gradle.ClassloaderContainer.fatJarClassLoader
import org.jetbrains.dokka.gradle.DokkaVersion.version
-import ru.yole.jkid.JsonExclude
-import ru.yole.jkid.serialization.serialize
+
import java.io.File
import java.io.InputStream
import java.io.Serializable
@@ -55,7 +56,6 @@ object ClassloaderContainer {
var fatJarClassLoader: ClassLoader? = null
}
-const val `deprecationMessage reportNotDocumented` = "Will be removed in 0.9.17, see dokka#243"
open class DokkaTask : DefaultTask() {
@@ -85,9 +85,6 @@ open class DokkaTask : DefaultTask() {
var outputDirectory: String = ""
var dokkaRuntime: Configuration? = null
- @Deprecated("Going to be removed in 0.9.16, use classpath + sourceDirs instead if kotlinTasks is not suitable for you")
- @Input var processConfigurations: List<Any?> = emptyList()
-
@InputFiles var classpath: Iterable<File> = arrayListOf()
@Input
@@ -110,15 +107,6 @@ open class DokkaTask : DefaultTask() {
@Input var includeNonPublic = false
@Input var skipDeprecated = false
@Input var skipEmptyPackages = true
-
- @Deprecated(`deprecationMessage reportNotDocumented`, replaceWith = ReplaceWith("reportUndocumented"))
- var reportNotDocumented
- get() = reportUndocumented
- set(value) {
- logger.warn("Dokka: reportNotDocumented is deprecated and " + `deprecationMessage reportNotDocumented`.decapitalize())
- reportUndocumented = value
- }
-
@Input var reportUndocumented = true
@Input var perPackageOptions: MutableList<PackageOptions> = arrayListOf()
@Input var impliedPlatforms: MutableList<String> = arrayListOf()
@@ -146,6 +134,9 @@ open class DokkaTask : DefaultTask() {
@get:Internal
internal val kotlinCompileBasedClasspathAndSourceRoots: ClasspathAndSourceRoots by lazy { extractClasspathAndSourceRootsFromKotlinTasks() }
+ @Optional @Input
+ var targets: List<String> = listOf()
+
private var kotlinTasksConfigurator: () -> List<Any?>? = { defaultKotlinTasks() }
private val kotlinTasks: List<Task> by lazy { extractKotlinCompileTasks() }
@@ -247,12 +238,12 @@ open class DokkaTask : DefaultTask() {
val tasksByPath = paths.map { taskContainer.findByPath(it as String) ?: throw IllegalArgumentException("Task with path '$it' not found") }
other
- .filter { it !is Task || it isNotInstance getAbstractKotlinCompileFor(it) }
- .forEach { throw IllegalArgumentException("Illegal entry in kotlinTasks, must be subtype of $ABSTRACT_KOTLIN_COMPILE or String, but was $it") }
+ .filter { it !is Task || it isNotInstance getAbstractKotlinCompileFor(it) }
+ .forEach { throw IllegalArgumentException("Illegal entry in kotlinTasks, must be subtype of $ABSTRACT_KOTLIN_COMPILE or String, but was $it") }
tasksByPath
- .filter { it == null || it isNotInstance getAbstractKotlinCompileFor(it) }
- .forEach { throw IllegalArgumentException("Illegal task path in kotlinTasks, must be subtype of $ABSTRACT_KOTLIN_COMPILE, but was $it") }
+ .filter { it == null || it isNotInstance getAbstractKotlinCompileFor(it) }
+ .forEach { throw IllegalArgumentException("Illegal task path in kotlinTasks, must be subtype of $ABSTRACT_KOTLIN_COMPILE, but was $it") }
return (tasksByPath + other) as List<Task>
@@ -275,9 +266,9 @@ open class DokkaTask : DefaultTask() {
val abstractKotlinCompileClz = getAbstractKotlinCompileFor(it)!!
val taskClasspath: Iterable<File> =
- (it["getClasspath", AbstractCompile::class].takeIfIsFunc()?.invoke()
- ?: it["compileClasspath", abstractKotlinCompileClz].takeIfIsProp()?.v()
- ?: it["getClasspath", abstractKotlinCompileClz]())
+ (it["getClasspath", AbstractCompile::class].takeIfIsFunc()?.invoke()
+ ?: it["compileClasspath", abstractKotlinCompileClz].takeIfIsProp()?.v()
+ ?: it["getClasspath", abstractKotlinCompileClz]())
if (taskClasspath is FileCollection) {
allClasspathFileCollection += taskClasspath
@@ -295,12 +286,14 @@ open class DokkaTask : DefaultTask() {
protected open fun collectSuppressedFiles(sourceRoots: List<SourceRoot>): List<String> = emptyList()
+ @ImplicitReflectionSerializer
@TaskAction
fun generate() {
if (dokkaRuntime == null){
dokkaRuntime = project.configurations.getByName("dokkaRuntime")
}
+
dokkaRuntime?.defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create(dokkaFatJar)) }
val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) ?: "false"
System.setProperty(COLORS_ENABLED_PROPERTY, "false")
@@ -309,65 +302,73 @@ open class DokkaTask : DefaultTask() {
val (tasksClasspath, tasksSourceRoots) = kotlinCompileBasedClasspathAndSourceRoots
- val project = project
val sourceRoots = collectSourceRoots() + tasksSourceRoots.toSourceRoots()
-
if (sourceRoots.isEmpty()) {
logger.warn("No source directories found: skipping dokka generation")
return
}
- val fullClasspath = collectClasspathFromOldSources() + tasksClasspath + classpath
+ val fullClasspath = tasksClasspath + classpath
val bootstrapClass = fatJarClassLoader!!.loadClass("org.jetbrains.dokka.DokkaBootstrapImpl")
-
val bootstrapInstance = bootstrapClass.constructors.first().newInstance()
-
val bootstrapProxy: DokkaBootstrap = automagicTypedProxy(javaClass.classLoader, bootstrapInstance)
- TODO("Fix Configuration in Gradle")
- /*
- val configuration = SerializeOnlyDokkaConfiguration(
- moduleName,
- fullClasspath.map { it.absolutePath },
- sourceRoots,
- samples.filterNotNull().map { project.file(it).absolutePath },
- includes.filterNotNull().map { project.file(it).absolutePath },
+
+ val configuration = DokkaConfigurationImpl(
outputDirectory,
outputFormat,
- includeNonPublic,
- false,
- reportUndocumented,
- skipEmptyPackages,
- skipDeprecated,
- jdkVersion,
true,
- linkMappings,
+ cacheRoot,
impliedPlatforms,
- perPackageOptions,
- externalDocumentationLinks,
- noStdlibLink,
- noJdkLink,
- cacheRoot,
- collectSuppressedFiles(sourceRoots),
- languageVersion,
- apiVersion,
- collectInheritedExtensionsFromLibraries
+ listOf(PassConfigurationImpl(
+ classpath= fullClasspath.map { it.absolutePath },
+ sourceRoots = sourceRoots.map { SourceRootImpl(it.path) },
+ samples = samples.filterNotNull().map { project.file(it).absolutePath },
+ includes = includes.filterNotNull().map { project.file(it).absolutePath },
+ collectInheritedExtensionsFromLibraries = collectInheritedExtensionsFromLibraries,
+ perPackageOptions = perPackageOptions.map{PackageOptionsImpl(
+ prefix = it.prefix,
+ includeNonPublic = it.includeNonPublic,
+ reportUndocumented = it.reportUndocumented,
+ skipDeprecated = it.skipDeprecated,
+ suppress = it.suppress
+ )},
+ moduleName = moduleName,
+ includeNonPublic = includeNonPublic,
+ includeRootPackage = false,
+ reportUndocumented = reportUndocumented,
+ skipEmptyPackages = skipEmptyPackages,
+ skipDeprecated = skipDeprecated,
+ jdkVersion = jdkVersion,
+ languageVersion = languageVersion,
+ apiVersion = apiVersion,
+ noStdlibLink = noStdlibLink,
+ noJdkLink = noJdkLink,
+ suppressedFiles = collectSuppressedFiles(sourceRoots),
+ sinceKotlin = "1.0",
+ analysisPlatform = Platform.DEFAULT,
+ targets = targets,
+ sourceLinks = mutableListOf(), // TODO: check this line
+ externalDocumentationLinks = externalDocumentationLinks.map {
+ ExternalDocumentationLinkImpl(it.url, it.packageListUrl)
+ }
+ )
+ )
)
-
bootstrapProxy.configure(
- BiConsumer { level, message ->
- when (level) {
- "info" -> logger.info(message)
- "warn" -> logger.warn(message)
- "error" -> logger.error(message)
- }
- },
- serialize(configuration)
+ BiConsumer { level, message ->
+ when (level) {
+ "info" -> logger.info(message)
+ "warn" -> logger.warn(message)
+ "error" -> logger.error(message)
+ }
+ },
+ Json.stringify(configuration)
)
- */
+
bootstrapProxy.generate()
} finally {
@@ -375,15 +376,6 @@ open class DokkaTask : DefaultTask() {
}
}
- private fun collectClasspathFromOldSources(): List<File> {
-
- val allConfigurations = project.configurations
-
- val fromConfigurations =
- processConfigurations.flatMap { allConfigurations.getByName(it.toString()) }
-
- return fromConfigurations
- }
private fun collectSourceRoots(): List<SourceRoot> {
val sourceDirs = if (sourceDirs.any()) {
@@ -406,7 +398,7 @@ open class DokkaTask : DefaultTask() {
@Classpath
fun getInputClasspath(): FileCollection {
val (classpathFileCollection) = extractClasspathAndSourceRootsFromKotlinTasks()
- return project.files(collectClasspathFromOldSources() + classpath) + classpathFileCollection
+ return project.files(classpath) + classpathFileCollection
}
@InputFiles
@@ -431,6 +423,7 @@ open class DokkaTask : DefaultTask() {
null
}
}
+
}
class SourceRoot : DokkaConfiguration.SourceRoot, Serializable {
@@ -443,7 +436,6 @@ class SourceRoot : DokkaConfiguration.SourceRoot, Serializable {
}
open class LinkMapping : Serializable, DokkaConfiguration.SourceLinkDefinition {
- @JsonExclude
var dir: String
get() = path
set(value) {
@@ -455,7 +447,6 @@ open class LinkMapping : Serializable, DokkaConfiguration.SourceLinkDefinition {
override var path: String = ""
override var url: String = ""
- @JsonExclude
var suffix: String?
get() = lineSuffix
set(value) {
diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle
index 2e9d0b1b..f8aaeba9 100644
--- a/runners/maven-plugin/build.gradle
+++ b/runners/maven-plugin/build.gradle
@@ -13,8 +13,8 @@ sourceCompatibility = 1.8
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
- languageVersion = "1.2"
- apiVersion = languageVersion
+ languageVersion = language_version
+ apiVersion = language_version
jvmTarget = "1.8"
}
}