From e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 31 Jan 2020 00:37:29 +0100 Subject: Bump Gradle version, migrate to Kotlin DSL, refactor publishing --- .../kotlin/org/jetbrains/dokka/DokkaBootstrap.kt | 10 --- .../main/kotlin/org/jetbrains/dokka/ReflectDsl.kt | 72 ---------------- .../kotlin/org/jetbrains/dokka/configuration.kt | 98 ---------------------- .../org/jetbrains/dokka/defaultConfiguration.kt | 74 ---------------- 4 files changed, 254 deletions(-) delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt (limited to 'integration/src/main/kotlin/org/jetbrains') diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt b/integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt deleted file mode 100644 index b78eb9c6..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.jetbrains.dokka - -import java.util.function.BiConsumer - -interface DokkaBootstrap { - - fun configure(logger: BiConsumer, serializedConfigurationJSON: String) - - fun generate() -} \ No newline at end of file diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt b/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt deleted file mode 100644 index 1984a3e5..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt +++ /dev/null @@ -1,72 +0,0 @@ -package org.jetbrains.dokka - -import kotlin.reflect.* -import kotlin.reflect.full.memberFunctions -import kotlin.reflect.full.memberProperties -import kotlin.reflect.jvm.isAccessible - -object ReflectDsl { - - class CallOrPropAccess(private val receiver: Any?, - private val clz: KClass<*>, - private val selector: String) { - - @Suppress("UNCHECKED_CAST") - operator fun invoke(vararg a: Any?): T { - return func!!.call(receiver, *a) as T - } - - operator fun get(s: String): CallOrPropAccess { - return v()!![s] - } - - val func: KFunction<*>? by lazy { clz.memberFunctions.find { it.name == selector } } - val prop: KProperty<*>? by lazy { clz.memberProperties.find { it.name == selector } } - - fun takeIfIsFunc(): CallOrPropAccess? = if (func != null) this else null - - fun takeIfIsProp(): CallOrPropAccess? = if (prop != null) this else null - - @Suppress("UNCHECKED_CAST") - fun v(): T { - val prop = prop!! - return try { - prop.getter.apply { isAccessible = true }.call(receiver) as T - } catch (e: KotlinNullPointerException) { - // Hack around kotlin-reflect bug KT-18480 - val jclass = clz.java - val customGetterName = prop.getter.name - val getterName = if (customGetterName.startsWith("<")) "get" + prop.name.capitalize() else customGetterName - val getter = jclass.getDeclaredMethod(getterName) - getter.isAccessible = true - - getter.invoke(receiver) as T - - } - } - - @Suppress("UNCHECKED_CAST") - fun v(x: Any?) { - (prop as KMutableProperty).setter.apply { isAccessible = true }.call(receiver, x) - } - - - } - - operator fun Any.get(s: String): CallOrPropAccess { - val clz = this.javaClass.kotlin - return CallOrPropAccess(this, clz, s) - } - - operator fun Any.get(s: String, clz: Class<*>): CallOrPropAccess { - val kclz = clz.kotlin - return CallOrPropAccess(this, kclz, s) - } - - operator fun Any.get(s: String, clz: KClass<*>): CallOrPropAccess { - return CallOrPropAccess(this, clz, s) - } - - inline infix fun Any.isInstance(clz: Class<*>?): Boolean = clz != null && clz.isAssignableFrom(this.javaClass) - inline infix fun Any.isNotInstance(clz: Class<*>?): Boolean = !(this isInstance clz) -} \ 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 deleted file mode 100644 index 8c6d35e8..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt +++ /dev/null @@ -1,98 +0,0 @@ -package org.jetbrains.dokka - -import java.io.File -import java.net.URL - -enum class Platform(val key: String) { - jvm("jvm"), - js("js"), - native("native"), - common("common"); - - companion object { - val DEFAULT = jvm - - fun fromString(key: String): Platform { - return when (key.toLowerCase()) { - jvm.key -> jvm - js.key -> js - native.key -> native - common.key -> common - else -> throw IllegalArgumentException("Unrecognized platform: $key") - } - } - } -} - -interface DokkaConfiguration { - val outputDir: String - val format: String - val generateIndexPages: Boolean - val cacheRoot: String? - val passesConfigurations: List - val impliedPlatforms: List - var pluginsClasspath: List - - interface PassConfiguration { - val moduleName: String - val classpath: List - val sourceRoots: List - val samples: List - val includes: List - val includeNonPublic: Boolean - val includeRootPackage: Boolean - val reportUndocumented: Boolean - val skipEmptyPackages: Boolean - val skipDeprecated: Boolean - val jdkVersion: Int - val sourceLinks: List - val perPackageOptions: List - val externalDocumentationLinks: List - val languageVersion: String? - val apiVersion: String? - val noStdlibLink: Boolean - val noJdkLink: Boolean - val suppressedFiles: List - val collectInheritedExtensionsFromLibraries: Boolean - val analysisPlatform: Platform - val targets: List - val sinceKotlin: String? - } - - interface SourceRoot { - val path: String - } - - interface SourceLinkDefinition { - val path: String - val url: String - val lineSuffix: String? - } - - interface PackageOptions { - val prefix: String - val includeNonPublic: Boolean - val reportUndocumented: Boolean - val skipDeprecated: Boolean - val suppress: Boolean - } - - interface ExternalDocumentationLink { - val url: URL - val packageListUrl: URL - - open class Builder(open var url: URL? = null, - open var packageListUrl: URL? = null) { - - constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) }) - - fun build(): 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") - } - } -} diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt deleted file mode 100644 index 6c797fcd..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt +++ /dev/null @@ -1,74 +0,0 @@ -package org.jetbrains.dokka - -import java.io.File -import java.net.URL - -data class DokkaConfigurationImpl( - override val outputDir: String, - override val format: String, - override val generateIndexPages: Boolean, - override val cacheRoot: String?, - override val impliedPlatforms: List, - override val passesConfigurations: List, - override var pluginsClasspath: List -) : DokkaConfiguration - -data class PassConfigurationImpl ( - override val moduleName: String, - override val classpath: List, - override val sourceRoots: List, - override val samples: List, - override val includes: List, - 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, - override val perPackageOptions: List, - override var externalDocumentationLinks: List, - override val languageVersion: String?, - override val apiVersion: String?, - override val noStdlibLink: Boolean, - override val noJdkLink: Boolean, - override val suppressedFiles: List, - override val collectInheritedExtensionsFromLibraries: Boolean, - override val analysisPlatform: Platform, - override val targets: List, - override val sinceKotlin: String? -) : DokkaConfiguration.PassConfiguration - - -data class SourceRootImpl( - override val path: String -): DokkaConfiguration.SourceRoot - -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" }) - } - } -} - -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 - - -data class ExternalDocumentationLinkImpl(override val url: URL, - override val packageListUrl: URL -) : DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file -- cgit