diff options
| author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-11-10 11:46:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-10 11:46:54 +0100 |
| commit | 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch) | |
| tree | 1b915207b2b9f61951ddbf0ff2e687efd053d555 /core/src/main/kotlin | |
| parent | a44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff) | |
| download | dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2 dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip | |
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing
* Update Gradle to 8.4
* Refactor and simplify convention plugins and build scripts
Fixes #3132
---------
Co-authored-by: Adam <897017+aSemy@users.noreply.github.com>
Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'core/src/main/kotlin')
65 files changed, 0 insertions, 4869 deletions
diff --git a/core/src/main/kotlin/ConfigurationJsonUtils.kt b/core/src/main/kotlin/ConfigurationJsonUtils.kt deleted file mode 100644 index e693f4ef..00000000 --- a/core/src/main/kotlin/ConfigurationJsonUtils.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - -import org.jetbrains.dokka.plugability.ConfigurableBlock -import org.jetbrains.dokka.utilities.parseJson -import org.jetbrains.dokka.utilities.serializeAsCompactJson -import org.jetbrains.dokka.utilities.serializeAsPrettyJson - -public fun DokkaConfigurationImpl(json: String): DokkaConfigurationImpl = parseJson(json) - -public fun GlobalDokkaConfiguration(json: String): GlobalDokkaConfiguration = parseJson(json) - -@Deprecated("Renamed to better distinguish between compact/pretty prints", ReplaceWith("this.toCompactJsonString()")) -public fun DokkaConfiguration.toJsonString(): String = this.toCompactJsonString() - -@Deprecated("Renamed to better distinguish between compact/pretty prints", ReplaceWith("this.toCompactJsonString()")) -public fun <T : ConfigurableBlock> T.toJsonString(): String = this.toCompactJsonString() - -/** - * Serializes [DokkaConfiguration] as a machine-readable and compact JSON string. - * - * The returned string is not very human friendly as it will be difficult to parse by eyes due to it - * being compact and in one line. If you want to show the output to a human being, see [toPrettyJsonString]. - */ -public fun DokkaConfiguration.toCompactJsonString(): String = serializeAsCompactJson(this) - -/** - * Serializes [DokkaConfiguration] as a human-readable (pretty printed) JSON string. - * - * The returned string will have excessive line breaks and indents, which might not be - * desirable when passing this value between API consumers/producers. If you want - * a machine-readable and compact json string, see [toCompactJsonString]. - */ -public fun DokkaConfiguration.toPrettyJsonString(): String = serializeAsPrettyJson(this) - -/** - * Serializes a [ConfigurableBlock] as a machine-readable and compact JSON string. - * - * The returned string is not very human friendly as it will be difficult to parse by eyes due to it - * being compact and in one line. If you want to show the output to a human being, see [toPrettyJsonString]. - */ -public fun <T : ConfigurableBlock> T.toCompactJsonString(): String = serializeAsCompactJson(this) - -/** - * Serializes a [ConfigurableBlock] as a human-readable (pretty printed) JSON string. - * - * The returned string will have excessive line breaks and indents, which might not be - * desirable when passing this value between API consumers/producers. If you want - * a machine-readable and compact json string, see [toCompactJsonString]. - */ -public fun <T : ConfigurableBlock> T.toPrettyJsonString(): String = serializeAsCompactJson(this) diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt deleted file mode 100644 index ca2504e2..00000000 --- a/core/src/main/kotlin/CoreExtensions.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - -import org.jetbrains.dokka.generation.Generation -import org.jetbrains.dokka.plugability.ExtensionPoint -import org.jetbrains.dokka.renderers.PostAction -import org.jetbrains.dokka.renderers.Renderer -import org.jetbrains.dokka.transformers.documentation.DocumentableMerger -import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator -import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer -import org.jetbrains.dokka.transformers.pages.PageTransformer -import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator -import org.jetbrains.dokka.validity.PreGenerationChecker -import kotlin.reflect.KProperty - -public object CoreExtensions { - - public val preGenerationCheck: ExtensionPoint<PreGenerationChecker> by coreExtensionPoint<PreGenerationChecker>() - - public val generation: ExtensionPoint<Generation> by coreExtensionPoint<Generation>() - - public val sourceToDocumentableTranslator: ExtensionPoint<SourceToDocumentableTranslator> by coreExtensionPoint<SourceToDocumentableTranslator>() - - public val documentableMerger: ExtensionPoint<DocumentableMerger> by coreExtensionPoint<DocumentableMerger>() - - public val documentableTransformer: ExtensionPoint<DocumentableTransformer> by coreExtensionPoint<DocumentableTransformer>() - - public val documentableToPageTranslator: ExtensionPoint<DocumentableToPageTranslator> by coreExtensionPoint<DocumentableToPageTranslator>() - - public val pageTransformer: ExtensionPoint<PageTransformer> by coreExtensionPoint<PageTransformer>() - - public val renderer: ExtensionPoint<Renderer> by coreExtensionPoint<Renderer>() - - public val postActions: ExtensionPoint<PostAction> by coreExtensionPoint<PostAction>() - - private fun <T : Any> coreExtensionPoint() = object { - operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<ExtensionPoint<T>> = - lazy { ExtensionPoint(thisRef::class.qualifiedName!!, property.name) } - } -} diff --git a/core/src/main/kotlin/DokkaBootstrap.kt b/core/src/main/kotlin/DokkaBootstrap.kt deleted file mode 100644 index d3d82e39..00000000 --- a/core/src/main/kotlin/DokkaBootstrap.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - -import java.util.function.BiConsumer - -public interface DokkaBootstrap { - @Throws(Throwable::class) - public fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) - - @Throws(Throwable::class) - public fun generate() -} diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt deleted file mode 100644 index 65f0ef72..00000000 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - -import org.jetbrains.dokka.utilities.DokkaLogger -import java.util.concurrent.atomic.AtomicInteger - -import java.util.function.BiConsumer - -/** - * Accessed with reflection - */ -@Suppress("unused") -public class DokkaBootstrapImpl : DokkaBootstrap { - - public class DokkaProxyLogger( - public val consumer: BiConsumer<String, String> - ) : DokkaLogger { - private val warningsCounter = AtomicInteger() - private val errorsCounter = AtomicInteger() - - override var warningsCount: Int - get() = warningsCounter.get() - set(value) = warningsCounter.set(value) - - override var errorsCount: Int - get() = errorsCounter.get() - set(value) = errorsCounter.set(value) - - override fun debug(message: String) { - consumer.accept("debug", message) - } - - override fun info(message: String) { - consumer.accept("info", message) - } - - override fun progress(message: String) { - consumer.accept("progress", message) - } - - override fun warn(message: String) { - consumer.accept("warn", message).also { warningsCounter.incrementAndGet() } - } - - override fun error(message: String) { - consumer.accept("error", message).also { errorsCounter.incrementAndGet() } - } - } - - private lateinit var generator: DokkaGenerator - - public fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) { - generator = DokkaGenerator(configuration, logger) - } - - override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) { - configure( - DokkaProxyLogger(logger), - DokkaConfigurationImpl(serializedConfigurationJSON) - ) - } - - override fun generate() { - generator.generate() - } -} diff --git a/core/src/main/kotlin/DokkaException.kt b/core/src/main/kotlin/DokkaException.kt deleted file mode 100644 index f16a2649..00000000 --- a/core/src/main/kotlin/DokkaException.kt +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - -public open class DokkaException(message: String) : RuntimeException(message) diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt deleted file mode 100644 index 9ae3adb4..00000000 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -@file:Suppress("SameParameterValue") - -package org.jetbrains.dokka - -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.Dispatchers -import org.jetbrains.dokka.generation.GracefulGenerationExit -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.utilities.DokkaLogger - -/** - * DokkaGenerator is the main entry point for generating documentation - * - * [generate] method has been split into submethods for test reasons - */ -public class DokkaGenerator( - private val configuration: DokkaConfiguration, - private val logger: DokkaLogger -) { - - public fun generate() { - timed(logger) { - report("Initializing plugins") - val context = initializePlugins(configuration, logger) - - runCatching { - context.single(CoreExtensions.generation).run { - logger.progress("Dokka is performing: $generationName") - generate() - } - }.exceptionOrNull()?.let { e -> - finalizeCoroutines() - throw e - } - - finalizeCoroutines() - }.dump("\n\n === TIME MEASUREMENT ===\n") - } - - public fun initializePlugins( - configuration: DokkaConfiguration, - logger: DokkaLogger, - additionalPlugins: List<DokkaPlugin> = emptyList() - ): DokkaContext = DokkaContext.create(configuration, logger, additionalPlugins) - - @OptIn(DelicateCoroutinesApi::class) - private fun finalizeCoroutines() { - if (configuration.finalizeCoroutines) { - Dispatchers.shutdown() - } - } -} - -public class Timer internal constructor(startTime: Long, private val logger: DokkaLogger?) { - private val steps = mutableListOf("" to startTime) - - public fun report(name: String) { - logger?.progress(name) - steps += (name to System.currentTimeMillis()) - } - - public fun dump(prefix: String = "") { - logger?.info(prefix) - val namePad = steps.map { it.first.length }.maxOrNull() ?: 0 - val timePad = steps.windowed(2).map { (p1, p2) -> p2.second - p1.second }.maxOrNull()?.toString()?.length ?: 0 - steps.windowed(2).forEach { (p1, p2) -> - if (p1.first.isNotBlank()) { - logger?.info("${p1.first.padStart(namePad)}: ${(p2.second - p1.second).toString().padStart(timePad)}") - } - } - } -} - -private fun timed(logger: DokkaLogger? = null, block: Timer.() -> Unit): Timer = - Timer(System.currentTimeMillis(), logger).apply { - try { - block() - } catch (exit: GracefulGenerationExit) { - report("Exiting Generation: ${exit.reason}") - } finally { - report("") - } - } - diff --git a/core/src/main/kotlin/DokkaVersion.kt b/core/src/main/kotlin/DokkaVersion.kt deleted file mode 100644 index d846988b..00000000 --- a/core/src/main/kotlin/DokkaVersion.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - -import java.util.* - -public object DokkaVersion { - public val version: String by lazy { - javaClass.getResourceAsStream("/META-INF/dokka/dokka-version.properties").use { stream -> - Properties().apply { load(stream) }.getProperty("dokka-version") - } - } -} diff --git a/core/src/main/kotlin/InternalDokkaApi.kt b/core/src/main/kotlin/InternalDokkaApi.kt deleted file mode 100644 index 65c0427c..00000000 --- a/core/src/main/kotlin/InternalDokkaApi.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - - -/** - * Marks declarations that are **internal** to Dokka core artifact. - * It means that this API is marked as **public** either for historical or technical reasons. - * It is not intended to be used outside of the Dokka project, has no behaviour guarantees, - * and may lack clear semantics, documentation and backward compatibility. - * - * If you are using such API, it is strongly suggested to migrate from it in order - * to keep backwards compatibility with future Dokka versions. - * Typically, the easiest way to do so is to copy-paste the corresponding utility into - * your own project. - */ -@RequiresOptIn( - level = RequiresOptIn.Level.ERROR, - message = "This is an internal Dokka API not intended for public use" -) -@Target( - AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD, - AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS -) -@Retention(AnnotationRetention.BINARY) -public annotation class InternalDokkaApi() diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt deleted file mode 100644 index 65035d04..00000000 --- a/core/src/main/kotlin/configuration.kt +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka - -import org.jetbrains.dokka.utilities.cast -import java.io.File -import java.io.Serializable -import java.net.URL - -public object DokkaDefaults { - public val moduleName: String = "root" - public val moduleVersion: String? = null - public val outputDir: File = File("./dokka") - public const val failOnWarning: Boolean = false - public const val suppressObviousFunctions: Boolean = true - public const val suppressInheritedMembers: Boolean = false - public const val offlineMode: Boolean = false - - public const val sourceSetDisplayName: String = "JVM" - public const val sourceSetName: String = "main" - public val analysisPlatform: Platform = Platform.DEFAULT - - public const val suppress: Boolean = false - public const val suppressGeneratedFiles: Boolean = true - - public const val skipEmptyPackages: Boolean = true - public const val skipDeprecated: Boolean = false - - public const val reportUndocumented: Boolean = false - - public const val noStdlibLink: Boolean = false - public const val noAndroidSdkLink: Boolean = false - public const val noJdkLink: Boolean = false - public const val jdkVersion: Int = 8 - - public const val includeNonPublic: Boolean = false - public val documentedVisibilities: Set<DokkaConfiguration.Visibility> = setOf(DokkaConfiguration.Visibility.PUBLIC) - - public val pluginsConfiguration: List<PluginConfigurationImpl> = mutableListOf() - - public const val delayTemplateSubstitution: Boolean = false - - public val cacheRoot: File? = null -} - -public enum class Platform( - public val key: String -) { - jvm("jvm"), - js("js"), - wasm("wasm"), - native("native"), - common("common"); - - public companion object { - public val DEFAULT: Platform = jvm - - public fun fromString(key: String): Platform { - return when (key.toLowerCase()) { - jvm.key -> jvm - js.key -> js - wasm.key -> wasm - native.key -> native - common.key -> common - "androidjvm", "android" -> jvm - "metadata" -> common - else -> throw IllegalArgumentException("Unrecognized platform: $key") - } - } - } -} - -public fun interface DokkaConfigurationBuilder<T : Any> { - public fun build(): T -} - -public fun <T : Any> Iterable<DokkaConfigurationBuilder<T>>.build(): List<T> = this.map { it.build() } - -public data class DokkaSourceSetID( - /** - * Unique identifier of the scope that this source set is placed in. - * Each scope provide only unique source set names. - * - * E.g. One DokkaTask inside the Gradle plugin represents one source set scope, since there cannot be multiple - * source sets with the same name. However, a Gradle project will not be a proper scope, since there can be - * multple DokkaTasks that contain source sets with the same name (but different configuration) - */ |
