From 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 10 Nov 2023 11:46:54 +0100 Subject: 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 --- core/src/main/kotlin/ConfigurationJsonUtils.kt | 54 --- core/src/main/kotlin/CoreExtensions.kt | 43 -- core/src/main/kotlin/DokkaBootstrap.kt | 15 - core/src/main/kotlin/DokkaBootstrapImpl.kt | 69 --- core/src/main/kotlin/DokkaException.kt | 7 - core/src/main/kotlin/DokkaGenerator.kt | 89 ---- core/src/main/kotlin/DokkaVersion.kt | 15 - core/src/main/kotlin/InternalDokkaApi.kt | 28 -- core/src/main/kotlin/configuration.kt | 280 ----------- core/src/main/kotlin/defaultConfiguration.kt | 100 ---- core/src/main/kotlin/defaultExternalLinks.kt | 33 -- core/src/main/kotlin/generation/Generation.kt | 19 - core/src/main/kotlin/links/DRI.kt | 146 ------ core/src/main/kotlin/model/CompositeSourceSetID.kt | 46 -- core/src/main/kotlin/model/DisplaySourceSet.kt | 61 --- core/src/main/kotlin/model/Documentable.kt | 540 --------------------- core/src/main/kotlin/model/JvmField.kt | 14 - core/src/main/kotlin/model/WithChildren.kt | 98 ---- core/src/main/kotlin/model/additionalExtras.kt | 142 ------ core/src/main/kotlin/model/ancestryNode.kt | 18 - core/src/main/kotlin/model/classKinds.kt | 24 - core/src/main/kotlin/model/defaultValues.kt | 34 -- core/src/main/kotlin/model/doc/DocTag.kt | 372 -------------- .../src/main/kotlin/model/doc/DocumentationNode.kt | 9 - core/src/main/kotlin/model/doc/TagWrapper.kt | 36 -- .../main/kotlin/model/documentableProperties.kt | 71 --- core/src/main/kotlin/model/documentableUtils.kt | 27 -- core/src/main/kotlin/model/extraModifiers.kt | 68 --- core/src/main/kotlin/model/jvmName.kt | 11 - .../kotlin/model/properties/PropertyContainer.kt | 69 --- .../src/main/kotlin/model/properties/properties.kt | 36 -- core/src/main/kotlin/pages/ContentNodes.kt | 436 ----------------- core/src/main/kotlin/pages/PageNodes.kt | 200 -------- core/src/main/kotlin/pages/Pages.kt | 15 - core/src/main/kotlin/pages/RendererSpecificPage.kt | 52 -- .../src/main/kotlin/pages/contentNodeProperties.kt | 37 -- core/src/main/kotlin/pages/utils.kt | 63 --- core/src/main/kotlin/plugability/DokkaContext.kt | 235 --------- .../src/main/kotlin/plugability/DokkaJavaPlugin.kt | 78 --- core/src/main/kotlin/plugability/DokkaPlugin.kt | 114 ----- core/src/main/kotlin/plugability/LazyEvaluated.kt | 21 - core/src/main/kotlin/plugability/extensions.kt | 110 ----- core/src/main/kotlin/renderers/PostAction.kt | 7 - core/src/main/kotlin/renderers/Renderer.kt | 11 - .../documentation/DefaultDocumentableMerger.kt | 307 ------------ .../documentation/DocumentableMerger.kt | 12 - .../documentation/DocumentableToPageTranslator.kt | 13 - .../documentation/DocumentableTransformer.kt | 12 - .../PreMergeDocumentableTransformer.kt | 39 -- .../main/kotlin/transformers/pages/PageCreator.kt | 15 - .../kotlin/transformers/pages/PageTransformer.kt | 11 - .../transformers/pages/PageTransformerBuilders.kt | 27 -- .../sources/AsyncSourceToDocumentableTranslator.kt | 20 - .../sources/SourceToDocumentableTranslator.kt | 13 - core/src/main/kotlin/utilities/Collections.kt | 29 -- core/src/main/kotlin/utilities/DokkaLogging.kt | 90 ---- core/src/main/kotlin/utilities/Html.kt | 23 - .../utilities/SelfRepresentingSingletonSet.kt | 27 -- core/src/main/kotlin/utilities/ServiceLocator.kt | 99 ---- core/src/main/kotlin/utilities/Uri.kt | 46 -- .../main/kotlin/utilities/associateWithNotNull.kt | 13 - core/src/main/kotlin/utilities/cast.kt | 12 - core/src/main/kotlin/utilities/json.kt | 65 --- .../utilities/parallelCollectionOperations.kt | 26 - .../main/kotlin/validity/PreGenerationChecker.kt | 17 - core/src/main/resources/META-INF/MANIFEST.MF | 1 - .../META-INF/dokka/dokka-version.properties | 5 - .../test/kotlin/model/CompositeSourceSetIDTest.kt | 76 --- core/src/test/kotlin/model/DisplaySourceSetTest.kt | 63 --- core/src/test/kotlin/model/DocumentableTest.kt | 115 ----- .../kotlin/utilities/DokkaConfigurationJsonTest.kt | 72 --- core/src/test/kotlin/utilities/JsonKtTest.kt | 80 --- 72 files changed, 5281 deletions(-) delete mode 100644 core/src/main/kotlin/ConfigurationJsonUtils.kt delete mode 100644 core/src/main/kotlin/CoreExtensions.kt delete mode 100644 core/src/main/kotlin/DokkaBootstrap.kt delete mode 100644 core/src/main/kotlin/DokkaBootstrapImpl.kt delete mode 100644 core/src/main/kotlin/DokkaException.kt delete mode 100644 core/src/main/kotlin/DokkaGenerator.kt delete mode 100644 core/src/main/kotlin/DokkaVersion.kt delete mode 100644 core/src/main/kotlin/InternalDokkaApi.kt delete mode 100644 core/src/main/kotlin/configuration.kt delete mode 100644 core/src/main/kotlin/defaultConfiguration.kt delete mode 100644 core/src/main/kotlin/defaultExternalLinks.kt delete mode 100644 core/src/main/kotlin/generation/Generation.kt delete mode 100644 core/src/main/kotlin/links/DRI.kt delete mode 100644 core/src/main/kotlin/model/CompositeSourceSetID.kt delete mode 100644 core/src/main/kotlin/model/DisplaySourceSet.kt delete mode 100644 core/src/main/kotlin/model/Documentable.kt delete mode 100644 core/src/main/kotlin/model/JvmField.kt delete mode 100644 core/src/main/kotlin/model/WithChildren.kt delete mode 100644 core/src/main/kotlin/model/additionalExtras.kt delete mode 100644 core/src/main/kotlin/model/ancestryNode.kt delete mode 100644 core/src/main/kotlin/model/classKinds.kt delete mode 100644 core/src/main/kotlin/model/defaultValues.kt delete mode 100644 core/src/main/kotlin/model/doc/DocTag.kt delete mode 100644 core/src/main/kotlin/model/doc/DocumentationNode.kt delete mode 100644 core/src/main/kotlin/model/doc/TagWrapper.kt delete mode 100644 core/src/main/kotlin/model/documentableProperties.kt delete mode 100644 core/src/main/kotlin/model/documentableUtils.kt delete mode 100644 core/src/main/kotlin/model/extraModifiers.kt delete mode 100644 core/src/main/kotlin/model/jvmName.kt delete mode 100644 core/src/main/kotlin/model/properties/PropertyContainer.kt delete mode 100644 core/src/main/kotlin/model/properties/properties.kt delete mode 100644 core/src/main/kotlin/pages/ContentNodes.kt delete mode 100644 core/src/main/kotlin/pages/PageNodes.kt delete mode 100644 core/src/main/kotlin/pages/Pages.kt delete mode 100644 core/src/main/kotlin/pages/RendererSpecificPage.kt delete mode 100644 core/src/main/kotlin/pages/contentNodeProperties.kt delete mode 100644 core/src/main/kotlin/pages/utils.kt delete mode 100644 core/src/main/kotlin/plugability/DokkaContext.kt delete mode 100644 core/src/main/kotlin/plugability/DokkaJavaPlugin.kt delete mode 100644 core/src/main/kotlin/plugability/DokkaPlugin.kt delete mode 100644 core/src/main/kotlin/plugability/LazyEvaluated.kt delete mode 100644 core/src/main/kotlin/plugability/extensions.kt delete mode 100644 core/src/main/kotlin/renderers/PostAction.kt delete mode 100644 core/src/main/kotlin/renderers/Renderer.kt delete mode 100644 core/src/main/kotlin/transformers/documentation/DefaultDocumentableMerger.kt delete mode 100644 core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt delete mode 100644 core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt delete mode 100644 core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt delete mode 100644 core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt delete mode 100644 core/src/main/kotlin/transformers/pages/PageCreator.kt delete mode 100644 core/src/main/kotlin/transformers/pages/PageTransformer.kt delete mode 100644 core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt delete mode 100644 core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt delete mode 100644 core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt delete mode 100644 core/src/main/kotlin/utilities/Collections.kt delete mode 100644 core/src/main/kotlin/utilities/DokkaLogging.kt delete mode 100644 core/src/main/kotlin/utilities/Html.kt delete mode 100644 core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt delete mode 100644 core/src/main/kotlin/utilities/ServiceLocator.kt delete mode 100644 core/src/main/kotlin/utilities/Uri.kt delete mode 100644 core/src/main/kotlin/utilities/associateWithNotNull.kt delete mode 100644 core/src/main/kotlin/utilities/cast.kt delete mode 100644 core/src/main/kotlin/utilities/json.kt delete mode 100644 core/src/main/kotlin/utilities/parallelCollectionOperations.kt delete mode 100644 core/src/main/kotlin/validity/PreGenerationChecker.kt delete mode 100644 core/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 core/src/main/resources/META-INF/dokka/dokka-version.properties delete mode 100644 core/src/test/kotlin/model/CompositeSourceSetIDTest.kt delete mode 100644 core/src/test/kotlin/model/DisplaySourceSetTest.kt delete mode 100644 core/src/test/kotlin/model/DocumentableTest.kt delete mode 100644 core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt delete mode 100644 core/src/test/kotlin/utilities/JsonKtTest.kt (limited to 'core/src') 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.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.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.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 by coreExtensionPoint() - - public val generation: ExtensionPoint by coreExtensionPoint() - - public val sourceToDocumentableTranslator: ExtensionPoint by coreExtensionPoint() - - public val documentableMerger: ExtensionPoint by coreExtensionPoint() - - public val documentableTransformer: ExtensionPoint by coreExtensionPoint() - - public val documentableToPageTranslator: ExtensionPoint by coreExtensionPoint() - - public val pageTransformer: ExtensionPoint by coreExtensionPoint() - - public val renderer: ExtensionPoint by coreExtensionPoint() - - public val postActions: ExtensionPoint by coreExtensionPoint() - - private fun coreExtensionPoint() = object { - operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy> = - 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) - - @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 - ) : 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) { - 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 = 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 = setOf(DokkaConfiguration.Visibility.PUBLIC) - - public val pluginsConfiguration: List = 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 { - public fun build(): T -} - -public fun Iterable>.build(): List = 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) - */ - val scopeId: String, - val sourceSetName: String -) : Serializable { - override fun toString(): String { - return "$scopeId/$sourceSetName" - } -} - -/** - * Global options can be configured and applied to all packages and modules at once, overwriting package configuration. - * - * These are handy if we have multiple source sets sharing the same global options as it reduces the size of the - * boilerplate. Otherwise, the user would be forced to repeat all these options for each source set. - * - * @see [apply] to learn how to apply global configuration - */ -public data class GlobalDokkaConfiguration( - val perPackageOptions: List?, - val externalDocumentationLinks: List?, - val sourceLinks: List? -) - -public fun DokkaConfiguration.apply(globals: GlobalDokkaConfiguration): DokkaConfiguration = this.apply { - sourceSets.forEach { - it.perPackageOptions.cast>() - .addAll(globals.perPackageOptions ?: emptyList()) - } - - sourceSets.forEach { - it.externalDocumentationLinks.cast>() - .addAll(globals.externalDocumentationLinks ?: emptyList()) - } - - sourceSets.forEach { - it.sourceLinks.cast>().addAll(globals.sourceLinks ?: emptyList()) - } -} - -public interface DokkaConfiguration : Serializable { - public val moduleName: String - public val moduleVersion: String? - public val outputDir: File - public val cacheRoot: File? - public val offlineMode: Boolean - public val failOnWarning: Boolean - public val sourceSets: List - public val modules: List - public val pluginsClasspath: List - public val pluginsConfiguration: List - public val delayTemplateSubstitution: Boolean - public val suppressObviousFunctions: Boolean - public val includes: Set - public val suppressInheritedMembers: Boolean - - /** - * Whether coroutines dispatchers should be shutdown after - * generating documentation via [DokkaGenerator.generate]. - * - * It effectively stops all background threads associated with - * coroutines in order to make classes unloadable by the JVM, - * and rejects all new tasks with [RejectedExecutionException] - * - * This is primarily useful for multi-module builds where coroutines - * can be shut down after each module's partial task to avoid - * possible memory leaks. - * - * However, this can lead to problems in specific lifecycles where - * coroutines are shared and will be reused after documentation generation, - * and closing it down will leave the build in an inoperable state. - * One such example is unit tests, for which finalization should be disabled. - */ - public val finalizeCoroutines: Boolean - - public enum class SerializationFormat : Serializable { - JSON, XML - } - - public interface PluginConfiguration : Serializable { - public val fqPluginName: String - public val serializationFormat: SerializationFormat - public val values: String - } - - public interface DokkaSourceSet : Serializable { - public val sourceSetID: DokkaSourceSetID - public val displayName: String - public val classpath: List - public val sourceRoots: Set - public val dependentSourceSets: Set - public val samples: Set - public val includes: Set - - @Deprecated(message = "Use [documentedVisibilities] property for a more flexible control over documented visibilities") - public val includeNonPublic: Boolean - public val reportUndocumented: Boolean - public val skipEmptyPackages: Boolean - public val skipDeprecated: Boolean - public val jdkVersion: Int - public val sourceLinks: Set - public val perPackageOptions: List - public val externalDocumentationLinks: Set - public val languageVersion: String? - public val apiVersion: String? - public val noStdlibLink: Boolean - public val noJdkLink: Boolean - public val suppressedFiles: Set - public val analysisPlatform: Platform - public val documentedVisibilities: Set - } - - public enum class Visibility { - /** - * `public` modifier for Java, default visibility for Kotlin - */ - PUBLIC, - - /** - * `private` modifier for both Kotlin and Java - */ - PRIVATE, - - /** - * `protected` modifier for both Kotlin and Java - */ - PROTECTED, - - /** - * Kotlin-specific `internal` modifier - */ - INTERNAL, - - /** - * Java-specific package-private visibility (no modifier) - */ - PACKAGE; - - public companion object { - public fun fromString(value: String): Visibility = valueOf(value.toUpperCase()) - } - } - - public interface SourceLinkDefinition : Serializable { - public val localDirectory: String - public val remoteUrl: URL - public val remoteLineSuffix: String? - } - - public interface DokkaModuleDescription : Serializable { - public val name: String - public val relativePathToOutputDirectory: File - public val sourceOutputDirectory: File - public val includes: Set - } - - public interface PackageOptions : Serializable { - public val matchingRegex: String - - @Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities") - public val includeNonPublic: Boolean - public val reportUndocumented: Boolean? - public val skipDeprecated: Boolean - public val suppress: Boolean - public val documentedVisibilities: Set - } - - public interface ExternalDocumentationLink : Serializable { - public val url: URL - public val packageListUrl: URL - - public companion object - } -} - -@Suppress("FunctionName") -public fun ExternalDocumentationLink( - url: URL? = null, - packageListUrl: URL? = null -): ExternalDocumentationLinkImpl { - return 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") -} - -@Suppress("FunctionName") -public fun ExternalDocumentationLink( - url: String, packageListUrl: String? = null -): ExternalDocumentationLinkImpl = - ExternalDocumentationLink(url.let(::URL), packageListUrl?.let(::URL)) diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt deleted file mode 100644 index f858d8c0..00000000 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ /dev/null @@ -1,100 +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.DokkaConfiguration.DokkaSourceSet -import java.io.File -import java.net.URL - -public data class DokkaConfigurationImpl( - override val moduleName: String = DokkaDefaults.moduleName, - override val moduleVersion: String? = DokkaDefaults.moduleVersion, - override val outputDir: File = DokkaDefaults.outputDir, - override val cacheRoot: File? = DokkaDefaults.cacheRoot, - override val offlineMode: Boolean = DokkaDefaults.offlineMode, - override val sourceSets: List = emptyList(), - override val pluginsClasspath: List = emptyList(), - override val pluginsConfiguration: List = DokkaDefaults.pluginsConfiguration, - override val modules: List = emptyList(), - override val failOnWarning: Boolean = DokkaDefaults.failOnWarning, - override val delayTemplateSubstitution: Boolean = false, - override val suppressObviousFunctions: Boolean = DokkaDefaults.suppressObviousFunctions, - override val includes: Set = emptySet(), - override val suppressInheritedMembers: Boolean = DokkaDefaults.suppressInheritedMembers, - override val finalizeCoroutines: Boolean = true, -) : DokkaConfiguration - -public data class PluginConfigurationImpl( - override val fqPluginName: String, - override val serializationFormat: DokkaConfiguration.SerializationFormat, - override val values: String -) : DokkaConfiguration.PluginConfiguration - - -public data class DokkaSourceSetImpl( - override val displayName: String = DokkaDefaults.sourceSetDisplayName, - override val sourceSetID: DokkaSourceSetID, - override val classpath: List = emptyList(), - override val sourceRoots: Set = emptySet(), - override val dependentSourceSets: Set = emptySet(), - override val samples: Set = emptySet(), - override val includes: Set = emptySet(), - @Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities") - override val includeNonPublic: Boolean = DokkaDefaults.includeNonPublic, - override val reportUndocumented: Boolean = DokkaDefaults.reportUndocumented, - override val skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages, - override val skipDeprecated: Boolean = DokkaDefaults.skipDeprecated, - override val jdkVersion: Int = DokkaDefaults.jdkVersion, - override val sourceLinks: Set = mutableSetOf(), - override val perPackageOptions: List = mutableListOf(), - override val externalDocumentationLinks: Set = mutableSetOf(), - override val languageVersion: String? = null, - override val apiVersion: String? = null, - override val noStdlibLink: Boolean = DokkaDefaults.noStdlibLink, - override val noJdkLink: Boolean = DokkaDefaults.noJdkLink, - override val suppressedFiles: Set = emptySet(), - override val analysisPlatform: Platform = DokkaDefaults.analysisPlatform, - override val documentedVisibilities: Set = DokkaDefaults.documentedVisibilities, -) : DokkaSourceSet - -public data class DokkaModuleDescriptionImpl( - override val name: String, - override val relativePathToOutputDirectory: File, - override val includes: Set, - override val sourceOutputDirectory: File -) : DokkaConfiguration.DokkaModuleDescription - -public data class SourceLinkDefinitionImpl( - override val localDirectory: String, - override val remoteUrl: URL, - override val remoteLineSuffix: String?, -) : DokkaConfiguration.SourceLinkDefinition { - - public companion object { - public fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl { - val (path, urlAndLine) = srcLink.split('=') - return SourceLinkDefinitionImpl( - localDirectory = File(path).canonicalPath, - remoteUrl = URL(urlAndLine.substringBefore("#")), - remoteLineSuffix = urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" }) - } - } -} - -public data class PackageOptionsImpl( - override val matchingRegex: String, - @Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities") - override val includeNonPublic: Boolean, - override val reportUndocumented: Boolean?, - override val skipDeprecated: Boolean, - override val suppress: Boolean, - override val documentedVisibilities: Set, // TODO add default to DokkaDefaults.documentedVisibilities -) : DokkaConfiguration.PackageOptions - - -public data class ExternalDocumentationLinkImpl( - override val url: URL, - override val packageListUrl: URL, -) : DokkaConfiguration.ExternalDocumentationLink diff --git a/core/src/main/kotlin/defaultExternalLinks.kt b/core/src/main/kotlin/defaultExternalLinks.kt deleted file mode 100644 index 26e3e0ae..00000000 --- a/core/src/main/kotlin/defaultExternalLinks.kt +++ /dev/null @@ -1,33 +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.DokkaConfiguration.ExternalDocumentationLink -import java.net.URL - - -public fun ExternalDocumentationLink.Companion.jdk(jdkVersion: Int): ExternalDocumentationLinkImpl = - ExternalDocumentationLink( - url = - if (jdkVersion < 11) "https://docs.oracle.com/javase/${jdkVersion}/docs/api/" - else "https://docs.oracle.com/en/java/javase/${jdkVersion}/docs/api/", - packageListUrl = - if (jdkVersion < 11) "https://docs.oracle.com/javase/${jdkVersion}/docs/api/package-list" - else "https://docs.oracle.com/en/java/javase/${jdkVersion}/docs/api/element-list" - ) - - -public fun ExternalDocumentationLink.Companion.kotlinStdlib(): ExternalDocumentationLinkImpl = - ExternalDocumentationLink("https://kotlinlang.org/api/latest/jvm/stdlib/") - - -public fun ExternalDocumentationLink.Companion.androidSdk(): ExternalDocumentationLinkImpl = - ExternalDocumentationLink("https://developer.android.com/reference/kotlin/") - - -public fun ExternalDocumentationLink.Companion.androidX(): ExternalDocumentationLinkImpl = ExternalDocumentationLink( - url = URL("https://developer.android.com/reference/kotlin/"), - packageListUrl = URL("https://developer.android.com/reference/kotlin/androidx/package-list") -) diff --git a/core/src/main/kotlin/generation/Generation.kt b/core/src/main/kotlin/generation/Generation.kt deleted file mode 100644 index 9f14912f..00000000 --- a/core/src/main/kotlin/generation/Generation.kt +++ /dev/null @@ -1,19 +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.generation - -import org.jetbrains.dokka.Timer - -public interface Generation { - public fun Timer.generate() - public val generationName: String -} - -// This needs to be public for now but in the future it should be replaced with system of checks provided by EP -public fun exitGenerationGracefully(reason: String): Nothing { - throw GracefulGenerationExit(reason) -} - -public class GracefulGenerationExit(public val reason: String) : Throwable() diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt deleted file mode 100644 index 180d9eb8..00000000 --- a/core/src/main/kotlin/links/DRI.kt +++ /dev/null @@ -1,146 +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.links - -import com.fasterxml.jackson.annotation.JsonTypeInfo -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.module.kotlin.readValue - -/** - * [DRI] stands for DokkaResourceIdentifier - */ -public data class DRI( - val packageName: String? = null, - val classNames: String? = null, - val callable: Callable? = null, - val target: DriTarget = PointingToDeclaration, - val extra: String? = null -) { - override fun toString(): String = - "${packageName.orEmpty()}/${classNames.orEmpty()}/${callable?.name.orEmpty()}/${callable?.signature() - .orEmpty()}/$target/${extra.orEmpty()}" - - public companion object { - public val topLevel: DRI = DRI() - } -} - -public object EnumEntryDRIExtra: DRIExtraProperty() - -public abstract class DRIExtraProperty { - public val key: String = this::class.qualifiedName - ?: (this.javaClass.let { it.`package`.name + "." + it.simpleName.ifEmpty { "anonymous" } }) -} - - -public class DRIExtraContainer(public val data: String? = null) { - public val map: MutableMap = if (data != null) OBJECT_MAPPER.readValue(data) else mutableMapOf() - public inline operator fun get(prop: DRIExtraProperty): T? = - map[prop.key]?.let { prop as? T } - - public inline operator fun set(prop: DRIExtraProperty, value: T) { - map[prop.key] = value as Any - } - - public fun encode(): String = OBJECT_MAPPER.writeValueAsString(map) - - private companion object { - private val OBJECT_MAPPER = ObjectMapper() - } -} - -public val DriOfUnit: DRI = DRI("kotlin", "Unit") -public val DriOfAny: DRI = DRI("kotlin", "Any") - -public fun DRI.withClass(name: String): DRI = copy(classNames = if (classNames.isNullOrBlank()) name else "$classNames.$name") - -public fun DRI.withTargetToDeclaration(): DRI = copy(target = PointingToDeclaration) - -public fun DRI.withEnumEntryExtra(): DRI = copy( - extra = DRIExtraContainer(this.extra).also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode() -) - -public val DRI.parent: DRI - get() = when { - extra != null -> when { - DRIExtraContainer(extra)[EnumEntryDRIExtra] != null -> copy( - classNames = classNames?.substringBeforeLast(".", "")?.takeIf { it.isNotBlank() }, - extra = null - ) - else -> copy(extra = null) - } - target != PointingToDeclaration -> copy(target = PointingToDeclaration) - callable != null -> copy(callable = null) - classNames != null -> copy(classNames = classNames.substringBeforeLast(".", "").takeIf { it.isNotBlank() }) - else -> DRI.topLevel - } - -public val DRI.sureClassNames: String - get() = classNames ?: throw IllegalStateException("Malformed DRI. It requires classNames in this context.") - -public data class Callable( - val name: String, - val receiver: TypeReference? = null, - val params: List -) { - public fun signature(): String = "${receiver?.toString().orEmpty()}#${params.joinToString("#")}" - - public companion object -} - -@JsonTypeInfo(use = CLASS) -public sealed class TypeReference { - public companion object -} - -public data class JavaClassReference(val name: String) : TypeReference() { - override fun toString(): String = name -} - -public data class TypeParam(val bounds: List) : TypeReference() - -public data class TypeConstructor( - val fullyQualifiedName: String, - val params: List -) : TypeReference() { - override fun toString(): String = fullyQualifiedName + - (if (params.isNotEmpty()) "[${params.joinToString(",")}]" else "") -} - -public data class RecursiveType(val rank: Int): TypeReference() { - override fun toString(): String = "^".repeat(rank + 1) -} - -public data class Nullable(val wrapped: TypeReference) : TypeReference() { - override fun toString(): String = "$wrapped?" -} - -public object StarProjection : TypeReference() { - override fun toString(): String = "*" -} - -@JsonTypeInfo(use = CLASS) -public sealed class DriTarget { - override fun toString(): String = this.javaClass.simpleName - - public companion object -} - -public data class PointingToGenericParameters(val parameterIndex: Int) : DriTarget() { - override fun toString(): String = "PointingToGenericParameters($parameterIndex)" -} - -public object PointingToDeclaration : DriTarget() - -public data class PointingToCallableParameters(val parameterIndex: Int) : DriTarget() { - override fun toString(): String = "PointingToCallableParameters($parameterIndex)" -} - -public fun DriTarget.nextTarget(): DriTarget = when (this) { - is PointingToGenericParameters -> PointingToGenericParameters(this.parameterIndex + 1) - is PointingToCallableParameters -> PointingToCallableParameters(this.parameterIndex + 1) - else -> this -} diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt deleted file mode 100644 index af7d1a5d..00000000 --- a/core/src/main/kotlin/model/CompositeSourceSetID.kt +++ /dev/null @@ -1,46 +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.model - -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.DokkaSourceSetID - -/** - * A unique composite key of multiple [DokkaSourceSetID] that identifies [DisplaySourceSet]. - * Consists of multiple (non-zero) [DokkaSourceSetID] that the corresponding [DisplaySourceSet] was built from. - * - * Should not be constructed or copied outside of [DisplaySourceSet] instantiation. - */ -public data class CompositeSourceSetID( - private val children: Set -) { - public constructor(sourceSetIDs: Iterable) : this(sourceSetIDs.toSet()) - public constructor(sourceSetId: DokkaSourceSetID) : this(setOf(sourceSetId)) - - init { - require(children.isNotEmpty()) { "Expected at least one source set id" } - } - - public val merged: DokkaSourceSetID = children.sortedBy { it.scopeId + it.sourceSetName }.let { sortedChildren -> - DokkaSourceSetID( - scopeId = sortedChildren.joinToString(separator = "+") { it.scopeId }, - sourceSetName = sortedChildren.joinToString(separator = "+") { it.sourceSetName } - ) - } - - public val all: Set = setOf(merged, *children.toTypedArray()) - - public operator fun contains(sourceSetId: DokkaSourceSetID): Boolean { - return sourceSetId in all - } - - public operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean { - return sourceSet.sourceSetID in this - } - - public operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID { - return copy(children = children + other) - } -} diff --git a/core/src/main/kotlin/model/DisplaySourceSet.kt b/core/src/main/kotlin/model/DisplaySourceSet.kt deleted file mode 100644 index 9d637048..00000000 --- a/core/src/main/kotlin/model/DisplaySourceSet.kt +++ /dev/null @@ -1,61 +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.model - -import org.jetbrains.dokka.* -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet - -/** - * Represents a final user-visible source set in the documentable model that is - * used to specify under which source sets/targets current signatures are available, - * can be used to filter in and out all available signatures under the specified source set, - * and, depending on the format, are rendered as "platform" selectors. - * - * E.g. HTML format renders display source sets as "bubbles" that later are used for filtering - * and informational purposes. - * - * [DisplaySourceSet]s typically have a one-to-one correspondence to the build system source sets, - * are created by the base plugin from [DokkaSourceSet] and never tweaked manually. - * [DisplaySourceSet] is uniquely identified by the corresponding [CompositeSourceSetID]. - * - * @property sourceSetIDs unique stable id of the display source set. - * It is composite by definition, as it uniquely defines the source set and all nested source sets. - * Apart from names, it also contains a substitute to a full source set path in order to differentiate - * source sets with the same name in a stable manner. - * @property name corresponds to the name of the original [DokkaSourceSet] - * @property platform the platform of the source set. If the source set is a mix of multiple source sets - * that correspond to multiple KMP platforms, then it is [Platform.common] - */ -public data class DisplaySourceSet( - val sourceSetIDs: CompositeSourceSetID, - val name: String, - val platform: Platform -) { - public constructor(sourceSet: DokkaSourceSet) : this( - sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID), - name = sourceSet.displayName, - platform = sourceSet.analysisPlatform - ) -} - -/** - * Transforms the current [DokkaSourceSet] into [DisplaySourceSet], - * matching the corresponding subset of its properties to [DisplaySourceSet] properties. - */ -public fun DokkaSourceSet.toDisplaySourceSet(): DisplaySourceSet = DisplaySourceSet(this) - -/** - * Transforms all the given [DokkaSourceSet]s into [DisplaySourceSet]s. - */ -public fun Iterable.toDisplaySourceSets(): Set = - map { it.toDisplaySourceSet() }.toSet() - -@InternalDokkaApi -@Deprecated("Use computeSourceSetIds() and cache its results instead", replaceWith = ReplaceWith("computeSourceSetIds()")) -public val Iterable.sourceSetIDs: List get() = this.flatMap { it.sourceSetIDs.all } - -@InternalDokkaApi -public fun Iterable.computeSourceSetIds(): Set = - fold(hashSetOf()) { acc, set -> acc.addAll(set.sourceSetIDs.all); acc } diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt deleted file mode 100644 index c6109f47..00000000 --- a/core/src/main/kotlin/model/Documentable.kt +++ /dev/null @@ -1,540 +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.model - -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.model.properties.PropertyContainer -import org.jetbrains.dokka.model.properties.WithExtraProperties - -public interface AnnotationTarget - -public abstract class Documentable : WithChildren, - AnnotationTarget { - public abstract val name: String? - public abstract val dri: DRI - public abstract val documentation: SourceSetDependent - public abstract val sourceSets: Set - public abstract val expectPresentInSet: DokkaSourceSet? - abstract override val children: List - - override fun toString(): String = - "${javaClass.simpleName}($dri)" - - override fun equals(other: Any?): Boolean = - other is Documentable && this.dri == other.dri // TODO: https://github.com/Kotlin/dokka/pull/667#discussion_r382555806 - - override fun hashCode(): Int = dri.hashCode() -} - -public typealias SourceSetDependent = Map - -public interface WithSources { - public val sources: SourceSetDependent -} - -public interface WithScope { - public val functions: List - public val properties: List - public val classlikes: List -} - -public interface WithVisibility { - public val visibility: SourceSetDependent -} - -public interface WithType { - public val type: Bound -} - -public interface WithAbstraction { - public val modifier: SourceSetDependent -} - -public sealed class Modifier( - public val name: String -) - -public sealed class KotlinModifier(name: String) : Modifier(name) { - public object Abstract : KotlinModifier("abstract") - public object Open : KotlinModifier("open") - public object Final : KotlinModifier("final") - public object Sealed : KotlinModifier("sealed") - public object Empty : KotlinModifier("") -} - -public sealed class JavaModifier(name: String) : Modifier(name) { - public object Abstract : JavaModifier("abstract") - public object Final : JavaModifier("final") - public object Empty : JavaModifier("") -} - -public interface WithCompanion { - public val companion: DObject? -} - -public interface WithConstructors { - public val constructors: List -} - -public interface WithGenerics { - public val generics: List -} - -public interface WithSupertypes { - public val supertypes: SourceSetDependent> -} - -public interface WithIsExpectActual { - public val isExpectActual: Boolean -} - -public interface Callable : WithVisibility, WithType, WithAbstraction, WithSources, WithIsExpectActual { - public val receiver: DParameter? -} - -public sealed class DClasslike : Documentable(), WithScope, WithVisibility, WithSources, WithIsExpectActual - -public data class DModule( - override val name: String, - val packages: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet? = null, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { - override val dri: DRI = DRI.topLevel - override val children: List - get() = packages - - override fun withNewExtras(newExtras: PropertyContainer): DModule = copy(extra = newExtras) -} - -public data class DPackage( - override val dri: DRI, - override val functions: List, - override val properties: List, - override val classlikes: List, - val typealiases: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet? = null, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { - - val packageName: String = dri.packageName.orEmpty() - - /** - * !!! WARNING !!! - * This name is not guaranteed to be a be a canonical/real package name. - * e.g. this will return a human readable version for root packages. - * Use [packageName] or `dri.packageName` instead to obtain the real packageName - */ - override val name: String = packageName.ifBlank { "[root]" } - - override val children: List = properties + functions + classlikes + typealiases - - override fun withNewExtras(newExtras: PropertyContainer): DPackage = copy(extra = newExtras) -} - -public data class DClass( - override val dri: DRI, - override val name: String, - override val constructors: List, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val sources: SourceSetDependent, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val generics: List, - override val supertypes: SourceSetDependent>, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val modifier: SourceSetDependent, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, - WithExtraProperties { - - override val children: List - get() = (functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer): DClass = copy(extra = newExtras) -} - -public data class DEnum( - override val dri: DRI, - override val name: String, - val entries: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val constructors: List, - override val supertypes: SourceSetDependent>, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties { - override val children: List - get() = (entries + functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer): DEnum = copy(extra = newExtras) -} - -public data class DEnumEntry( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { - override val children: List - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer): DEnumEntry = copy(extra = newExtras) -} - -public data class DFunction( - override val dri: DRI, - override val name: String, - val isConstructor: Boolean, - val parameters: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val visibility: SourceSetDependent, - override val type: Bound, - override val generics: List, - override val receiver: DParameter?, - override val modifier: SourceSetDependent, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithGenerics, WithExtraProperties { - override val children: List - get() = parameters - - override fun withNewExtras(newExtras: PropertyContainer): DFunction = copy(extra = newExtras) -} - -public data class DInterface( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val generics: List, - override val supertypes: SourceSetDependent>, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties { - override val children: List - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer): DInterface = copy(extra = newExtras) -} - -public data class DObject( - override val name: String?, - override val dri: DRI, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val supertypes: SourceSetDependent>, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithSupertypes, WithExtraProperties { - override val children: List - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer): DObject = copy(extra = newExtras) -} - -public data class DAnnotation( - override val name: String, - override val dri: DRI, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val constructors: List, - override val generics: List, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContai