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 - 65 files changed, 4869 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 (limited to 'core/src/main/kotlin') 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 = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties, WithGenerics { - override val children: List - get() = (functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer): DAnnotation = copy(extra = newExtras) -} - -public data class DProperty( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val visibility: SourceSetDependent, - override val type: Bound, - override val receiver: DParameter?, - val setter: DFunction?, - val getter: DFunction?, - override val modifier: SourceSetDependent, - override val sourceSets: Set, - override val generics: List, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithExtraProperties, WithGenerics { - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DProperty = copy(extra = newExtras) -} - -// TODO: treat named Parameters and receivers differently -public data class DParameter( - override val dri: DRI, - override val name: String?, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val type: Bound, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties, WithType { - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DParameter = copy(extra = newExtras) -} - -public data class DTypeParameter( - val variantTypeParameter: Variance, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - val bounds: List, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { - - public constructor( - dri: DRI, - name: String, - presentableName: String?, - documentation: SourceSetDependent, - expectPresentInSet: DokkaSourceSet?, - bounds: List, - sourceSets: Set, - extra: PropertyContainer = PropertyContainer.empty() - ) : this( - Invariance(TypeParameter(dri, name, presentableName)), - documentation, - expectPresentInSet, - bounds, - sourceSets, - extra - ) - - override val dri: DRI by variantTypeParameter.inner::dri - override val name: String by variantTypeParameter.inner::name - - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DTypeParameter = copy(extra = newExtras) -} - -public data class DTypeAlias( - override val dri: DRI, - override val name: String, - override val type: Bound, - val underlyingType: SourceSetDependent, - override val visibility: SourceSetDependent, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sourceSets: Set, - override val generics: List, - override val sources: SourceSetDependent, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithType, WithVisibility, WithExtraProperties, WithGenerics, WithSources { - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DTypeAlias = copy(extra = newExtras) -} - -public sealed class Projection -public sealed class Bound : Projection() -public data class TypeParameter( - val dri: DRI, - val name: String, - val presentableName: String? = null, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): TypeParameter = - copy(extra = extra) -} - -public sealed class TypeConstructor : Bound(), AnnotationTarget { - public abstract val dri: DRI - public abstract val projections: List - public abstract val presentableName: String? -} - -public data class GenericTypeConstructor( - override val dri: DRI, - override val projections: List, - override val presentableName: String? = null, - override val extra: PropertyContainer = PropertyContainer.empty() -) : TypeConstructor(), WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): GenericTypeConstructor = - copy(extra = newExtras) -} - -public data class FunctionalTypeConstructor( - override val dri: DRI, - override val projections: List, - val isExtensionFunction: Boolean = false, - val isSuspendable: Boolean = false, - override val presentableName: String? = null, - override val extra: PropertyContainer = PropertyContainer.empty(), -) : TypeConstructor(), WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): FunctionalTypeConstructor = - copy(extra = newExtras) -} - -// kotlin.annotation.AnnotationTarget.TYPEALIAS -public data class TypeAliased( - val typeAlias: Bound, - val inner: Bound, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): TypeAliased = - copy(extra = newExtras) -} - -public data class PrimitiveJavaType( - val name: String, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): PrimitiveJavaType = - copy(extra = newExtras) -} - -public data class JavaObject(override val extra: PropertyContainer = PropertyContainer.empty()) : - Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): JavaObject = - copy(extra = newExtras) -} - -public data class UnresolvedBound( - val name: String, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): UnresolvedBound = - copy(extra = newExtras) -} - -// The following Projections are not AnnotationTargets; they cannot be annotated. -public data class Nullable(val inner: Bound) : Bound() - -/** - * It introduces [definitely non-nullable types](https://github.com/Kotlin/KEEP/blob/c72601cf35c1e95a541bb4b230edb474a6d1d1a8/proposals/definitely-non-nullable-types.md) - */ -public data class DefinitelyNonNullable(val inner: Bound) : Bound() - -public sealed class Variance : Projection() { - public abstract val inner: T -} - -public data class Covariance(override val inner: T) : Variance() { - override fun toString(): String = "out" -} - -public data class Contravariance(override val inner: T) : Variance() { - override fun toString(): String = "in" -} - -public data class Invariance(override val inner: T) : Variance() { - override fun toString(): String = "" -} - -public object Star : Projection() - -public object Void : Bound() -public object Dynamic : Bound() - -public fun Variance.withDri(dri: DRI): Variance = when (this) { - is Contravariance -> Contravariance(TypeParameter(dri, inner.name, inner.presentableName)) - is Covariance -> Covariance(TypeParameter(dri, inner.name, inner.presentableName)) - is Invariance -> Invariance(TypeParameter(dri, inner.name, inner.presentableName)) -} - -public fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = - if (predicate(this)) { - this - } else { - this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() - } - -public sealed class Visibility(public val name: String) - -public sealed class KotlinVisibility(name: String) : Visibility(name) { - public object Public : KotlinVisibility("public") - public object Private : KotlinVisibility("private") - public object Protected : KotlinVisibility("protected") - public object Internal : KotlinVisibility("internal") -} - -public sealed class JavaVisibility(name: String) : Visibility(name) { - public object Public : JavaVisibility("public") - public object Private : JavaVisibility("private") - public object Protected : JavaVisibility("protected") - public object Default : JavaVisibility("") -} - -public fun SourceSetDependent?.orEmpty(): SourceSetDependent = this ?: emptyMap() - -public interface DocumentableSource { - public val path: String - - /** - * Computes the first line number of the documentable's declaration/signature/identifier. - * - * Numbering is always 1-based. - * - * May return null if the sources could not be found - for example, for synthetic/generated declarations. - */ - public fun computeLineNumber(): Int? -} - -public data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind) diff --git a/core/src/main/kotlin/model/JvmField.kt b/core/src/main/kotlin/model/JvmField.kt deleted file mode 100644 index a2b641c9..00000000 --- a/core/src/main/kotlin/model/JvmField.kt +++ /dev/null @@ -1,14 +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.links.DRI - -public const val JVM_FIELD_PACKAGE_NAME: String = "kotlin.jvm" -public const val JVM_FIELD_CLASS_NAMES: String = "JvmField" - -public fun DRI.isJvmField(): Boolean = packageName == JVM_FIELD_PACKAGE_NAME && classNames == JVM_FIELD_CLASS_NAMES - -public fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmField() diff --git a/core/src/main/kotlin/model/WithChildren.kt b/core/src/main/kotlin/model/WithChildren.kt deleted file mode 100644 index f73a5aa0..00000000 --- a/core/src/main/kotlin/model/WithChildren.kt +++ /dev/null @@ -1,98 +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 - -public interface WithChildren { - public val children: List -} - -public inline fun WithChildren<*>.firstChildOfTypeOrNull(): T? = - children.filterIsInstance().firstOrNull() - -public inline fun WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = - children.filterIsInstance().firstOrNull(predicate) - -public inline fun WithChildren<*>.firstChildOfType(): T = - children.filterIsInstance().first() - -public inline fun WithChildren<*>.childrenOfType(): List = - children.filterIsInstance() - -public inline fun WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = - children.filterIsInstance().first(predicate) - -public inline fun WithChildren>.firstMemberOfType(): T where T : WithChildren<*> { - return withDescendants().filterIsInstance().first() -} - -public inline fun WithChildren>.firstMemberOfType( - predicate: (T) -> Boolean -): T where T : WithChildren<*> = withDescendants().filterIsInstance().first(predicate) - - -public inline fun WithChildren>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { - return withDescendants().filterIsInstance().firstOrNull() -} - -public fun T.withDescendants(): Sequence where T : WithChildren { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - yieldAll(child.withDescendants()) - } - } -} - -@JvmName("withDescendantsProjection") -public fun WithChildren<*>.withDescendants(): Sequence { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - if (child is WithChildren<*>) { - yieldAll(child.withDescendants()) - } - } - } -} - -@JvmName("withDescendantsAny") -public fun WithChildren.withDescendants(): Sequence { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - if (child is WithChildren<*>) { - yieldAll(child.withDescendants().filterNotNull()) - } - } - } -} - -public fun T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren = if (predicate(this)) { - this -} else { - children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() -} - -public fun > T.asPrintableTree( - nodeNameBuilder: Appendable.(T) -> Unit = { append(it.toString()) } -): String { - fun Appendable.append(element: T, ownPrefix: String, childPrefix: String) { - append(ownPrefix) - nodeNameBuilder(element) - appendLine() - element.children.takeIf(Collection<*>::isNotEmpty)?.also { children -> - val newOwnPrefix = "$childPrefix├─ " - val lastOwnPrefix = "$childPrefix└─ " - val newChildPrefix = "$childPrefix│ " - val lastChildPrefix = "$childPrefix " - children.forEachIndexed { n, e -> - if (n != children.lastIndex) append(e, newOwnPrefix, newChildPrefix) - else append(e, lastOwnPrefix, lastChildPrefix) - } - } - } - - return buildString { append(this@asPrintableTree, "", "") } -} diff --git a/core/src/main/kotlin/model/additionalExtras.kt b/core/src/main/kotlin/model/additionalExtras.kt deleted file mode 100644 index 1db8e59d..00000000 --- a/core/src/main/kotlin/model/additionalExtras.kt +++ /dev/null @@ -1,142 +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.links.DRI -import org.jetbrains.dokka.model.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy - -public class AdditionalModifiers( - public val content: SourceSetDependent> -) : ExtraProperty { - - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor( - left: AdditionalModifiers, - right: AdditionalModifiers - ): MergeStrategy = MergeStrategy.Replace(AdditionalModifiers(left.content + right.content)) - } - - override fun equals(other: Any?): Boolean = - if (other is AdditionalModifiers) other.content == content else false - - override fun hashCode(): Int = content.hashCode() - override val key: ExtraProperty.Key = AdditionalModifiers -} - -public fun SourceSetDependent>.toAdditionalModifiers(): AdditionalModifiers = AdditionalModifiers(this) - -public data class Annotations( - private val myContent: SourceSetDependent> -) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy = - MergeStrategy.Replace(Annotations(left.myContent + right.myContent)) - } - - override val key: ExtraProperty.Key = Annotations - - public data class Annotation( - val dri: DRI, - val params: Map, - val mustBeDocumented: Boolean = false, - val scope: AnnotationScope = AnnotationScope.DIRECT - ) { - override fun equals(other: Any?): Boolean = when (other) { - is Annotation -> dri == other.dri - else -> false - } - - override fun hashCode(): Int = dri.hashCode() - } - - @Deprecated("Use directAnnotations or fileLevelAnnotations") - val content: SourceSetDependent> - get() = myContent - - val directAnnotations: SourceSetDependent> = annotationsByScope(AnnotationScope.DIRECT) - - val fileLevelAnnotations: SourceSetDependent> = annotationsByScope(AnnotationScope.FILE) - - private fun annotationsByScope(scope: AnnotationScope): SourceSetDependent> = - myContent.entries.mapNotNull { (key, value) -> - val withoutFileLevel = value.filter { it.scope == scope } - if (withoutFileLevel.isEmpty()) null - else Pair(key, withoutFileLevel) - }.toMap() - - public enum class AnnotationScope { - DIRECT, FILE, GETTER, SETTER - } -} - -public fun SourceSetDependent>.toAnnotations(): Annotations = Annotations(this) - -public sealed class AnnotationParameterValue - -public data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() - -public data class ArrayValue(val value: List) : AnnotationParameterValue() - -public data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() - -public data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() - -public abstract class LiteralValue : AnnotationParameterValue() { - public abstract fun text() : String -} -public data class IntValue(val value: Int) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class LongValue(val value: Long) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class FloatValue(val value: Float) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class DoubleValue(val value: Double) : LiteralValue() { - override fun text(): String = value.toString() -} - -public object NullValue : LiteralValue() { - override fun text(): String = "null" -} - -public data class BooleanValue(val value: Boolean) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class StringValue(val value: String) : LiteralValue() { - override fun text(): String = value - override fun toString(): String = value -} - -public object PrimaryConstructorExtra : ExtraProperty, ExtraProperty.Key { - override val key: ExtraProperty.Key = this -} - -public data class ActualTypealias( - val typeAlias: DTypeAlias -) : ExtraProperty { - - @Suppress("unused") - @Deprecated(message = "It can be removed soon. Use [typeAlias.underlyingType]", ReplaceWith("this.typeAlias.underlyingType")) - val underlyingType: SourceSetDependent - get() = typeAlias.underlyingType - - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor( - left: ActualTypealias, - right: ActualTypealias - ): MergeStrategy = MergeStrategy.Fail { - throw IllegalStateException("Adding [ActualTypealias] should be after merging all documentables") - } - } - - override val key: ExtraProperty.Key = ActualTypealias -} diff --git a/core/src/main/kotlin/model/ancestryNode.kt b/core/src/main/kotlin/model/ancestryNode.kt deleted file mode 100644 index 7203ab18..00000000 --- a/core/src/main/kotlin/model/ancestryNode.kt +++ /dev/null @@ -1,18 +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 - -public data class AncestryNode( - val typeConstructor: TypeConstructor, - val superclass: AncestryNode?, - val interfaces: List, -) { - public fun allImplementedInterfaces(): List { - fun traverseInterfaces(ancestry: AncestryNode): List = - ancestry.interfaces.flatMap { listOf(it.typeConstructor) + traverseInterfaces(it) } + - (ancestry.superclass?.let(::traverseInterfaces) ?: emptyList()) - return traverseInterfaces(this).distinct() - } -} diff --git a/core/src/main/kotlin/model/classKinds.kt b/core/src/main/kotlin/model/classKinds.kt deleted file mode 100644 index 25256022..00000000 --- a/core/src/main/kotlin/model/classKinds.kt +++ /dev/null @@ -1,24 +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 - -public interface ClassKind - -public enum class KotlinClassKindTypes : ClassKind { - CLASS, - INTERFACE, - ENUM_CLASS, - ENUM_ENTRY, - ANNOTATION_CLASS, - OBJECT; -} - -public enum class JavaClassKindTypes : ClassKind { - CLASS, - INTERFACE, - ENUM_CLASS, - ENUM_ENTRY, - ANNOTATION_CLASS; -} diff --git a/core/src/main/kotlin/model/defaultValues.kt b/core/src/main/kotlin/model/defaultValues.kt deleted file mode 100644 index 426954fb..00000000 --- a/core/src/main/kotlin/model/defaultValues.kt +++ /dev/null @@ -1,34 +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.model.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy - -public class DefaultValue( - public val expression: SourceSetDependent -): ExtraProperty { - - @Deprecated("Use `expression` property that depends on source set", ReplaceWith("this.expression.values.first()")) - public val value: Expression - get() = expression.values.first() - - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: DefaultValue, right: DefaultValue): MergeStrategy = - MergeStrategy.Replace(DefaultValue(left.expression + right.expression)) - - } - - override val key: ExtraProperty.Key - get() = Companion -} - -public interface Expression -public data class ComplexExpression(val value: String) : Expression -public data class IntegerConstant(val value: Long) : Expression -public data class StringConstant(val value: String) : Expression -public data class DoubleConstant(val value: Double) : Expression -public data class FloatConstant(val value: Float) : Expression -public data class BooleanConstant(val value: Boolean) : Expression diff --git a/core/src/main/kotlin/model/doc/DocTag.kt b/core/src/main/kotlin/model/doc/DocTag.kt deleted file mode 100644 index f4cb9b33..00000000 --- a/core/src/main/kotlin/model/doc/DocTag.kt +++ /dev/null @@ -1,372 +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.doc - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.WithChildren - -public sealed class DocTag : WithChildren { - public abstract val params: Map - - public companion object { - public fun contentTypeParam(type: String): Map = mapOf("content-type" to type) - } -} - -public data class A( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Big( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class B( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class BlockQuote( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public object Br : DocTag() { - override val children: List = emptyList() - override val params: Map = emptyMap() -} - -public data class Cite( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public sealed class Code : DocTag() - -public data class CodeInline( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : Code() - -public data class CodeBlock( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : Code() - -public data class CustomDocTag( - override val children: List = emptyList(), - override val params: Map = emptyMap(), - val name: String -) : DocTag() - -public data class Dd( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dfn( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dir( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Div( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dl( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class DocumentationLink( - val dri: DRI, - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dt( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Em( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Font( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Footer( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Frame( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class FrameSet( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H1( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H2( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H3( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H4( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H5( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H6( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Head( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Header( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public object HorizontalRule : DocTag() { - override val children: List = emptyList() - override val params: Map = emptyMap() -} - -public data class Html( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class I( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class IFrame( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Img( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Index( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Input( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Li( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Link( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Listing( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Main( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Menu( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Meta( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Nav( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class NoFrames( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class NoScript( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Ol( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class P( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Pre( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Script( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Section( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Small( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Span( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Strikethrough( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Strong( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Sub( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Sup( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Table( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Text( - val body: String = "", - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class TBody( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Td( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class TFoot( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Th( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class THead( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Title( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Tr( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Tt( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class U( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Ul( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Var( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Caption( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - diff --git a/core/src/main/kotlin/model/doc/DocumentationNode.kt b/core/src/main/kotlin/model/doc/DocumentationNode.kt deleted file mode 100644 index 9c270f79..00000000 --- a/core/src/main/kotlin/model/doc/DocumentationNode.kt +++ /dev/null @@ -1,9 +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.doc - -import org.jetbrains.dokka.model.WithChildren - -public data class DocumentationNode(override val children: List): WithChildren diff --git a/core/src/main/kotlin/model/doc/TagWrapper.kt b/core/src/main/kotlin/model/doc/TagWrapper.kt deleted file mode 100644 index e3eaffb7..00000000 --- a/core/src/main/kotlin/model/doc/TagWrapper.kt +++ /dev/null @@ -1,36 +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.doc - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.WithChildren - -public sealed class TagWrapper : WithChildren { - public abstract val root: DocTag - - override val children: List - get() = root.children -} - -public sealed class NamedTagWrapper : TagWrapper() { - public abstract val name: String -} - -public data class Description(override val root: DocTag) : TagWrapper() -public data class Author(override val root: DocTag) : TagWrapper() -public data class Version(override val root: DocTag) : TagWrapper() -public data class Since(override val root: DocTag) : TagWrapper() -public data class See(override val root: DocTag, override val name: String, val address: DRI?) : NamedTagWrapper() -public data class Param(override val root: DocTag, override val name: String) : NamedTagWrapper() -public data class Return(override val root: DocTag) : TagWrapper() -public data class Receiver(override val root: DocTag) : TagWrapper() -public data class Constructor(override val root: DocTag) : TagWrapper() -//TODO this naming is confusing since kotlin has Throws annotation -public data class Throws(override val root: DocTag, override val name: String, val exceptionAddress: DRI?) : NamedTagWrapper() -public data class Sample(override val root: DocTag, override val name: String) : NamedTagWrapper() -public data class Deprecated(override val root: DocTag) : TagWrapper() -public data class Property(override val root: DocTag, override val name: String) : NamedTagWrapper() -public data class Suppress(override val root: DocTag) : TagWrapper() -public data class CustomTagWrapper(override val root: DocTag, override val name: String) : NamedTagWrapper() diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt deleted file mode 100644 index b0ebb6ef..00000000 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ /dev/null @@ -1,71 +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.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy - -public data class InheritedMember(val inheritedFrom: SourceSetDependent) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember): MergeStrategy = MergeStrategy.Replace( - InheritedMember(left.inheritedFrom + right.inheritedFrom) - ) - } - - public fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null - - override val key: ExtraProperty.Key = InheritedMember -} - -public data class ImplementedInterfaces(val interfaces: SourceSetDependent>) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces): MergeStrategy = - MergeStrategy.Replace(ImplementedInterfaces(left.interfaces + right.interfaces)) - } - - override val key: ExtraProperty.Key = ImplementedInterfaces -} - -public data class ExceptionInSupertypes(val exceptions: SourceSetDependent>): ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes): MergeStrategy = - MergeStrategy.Replace(ExceptionInSupertypes(left.exceptions + right.exceptions)) - } - - override val key: ExtraProperty.Key = ExceptionInSupertypes -} - -public object ObviousMember : ExtraProperty, ExtraProperty.Key { - override val key: ExtraProperty.Key = this -} - -/** - * Whether this [DProperty] is `var` or `val`, should be present both in Kotlin and in Java properties - * - * In case of properties that came from `Java`, [IsVar] is added if - * the java field has no accessors at all (plain field) or has a setter - */ -public object IsVar : ExtraProperty, ExtraProperty.Key { - override val key: ExtraProperty.Key = this -} - -public data class IsAlsoParameter(val inSourceSets: List) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: IsAlsoParameter, right: IsAlsoParameter): MergeStrategy = - MergeStrategy.Replace(IsAlsoParameter(left.inSourceSets + right.inSourceSets)) - } - - override val key: ExtraProperty.Key = IsAlsoParameter -} - -public data class CheckedExceptions(val exceptions: SourceSetDependent>) : ExtraProperty, ExtraProperty.Key { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions): MergeStrategy = - MergeStrategy.Replace(CheckedExceptions(left.exceptions + right.exceptions)) - } - override val key: ExtraProperty.Key = CheckedExceptions -} diff --git a/core/src/main/kotlin/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt deleted file mode 100644 index c9d75bf4..00000000 --- a/core/src/main/kotlin/model/documentableUtils.kt +++ /dev/null @@ -1,27 +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 - -public fun SourceSetDependent.filtered(sourceSets: Set): SourceSetDependent = filter { it.key in sourceSets } -public fun DokkaSourceSet?.filtered(sourceSets: Set): DokkaSourceSet? = takeIf { this in sourceSets } - -public fun DTypeParameter.filter(filteredSet: Set): DTypeParameter? = - if (filteredSet.containsAll(sourceSets)) this - else { - val intersection = filteredSet.intersect(sourceSets) - if (intersection.isEmpty()) null - else DTypeParameter( - variantTypeParameter, - documentation.filtered(intersection), - expectPresentInSet?.takeIf { intersection.contains(expectPresentInSet) }, - bounds, - intersection, - extra - ) - } - -public fun Documentable.isExtension(): Boolean = this is Callable && receiver != null diff --git a/core/src/main/kotlin/model/extraModifiers.kt b/core/src/main/kotlin/model/extraModifiers.kt deleted file mode 100644 index f1193070..00000000 --- a/core/src/main/kotlin/model/extraModifiers.kt +++ /dev/null @@ -1,68 +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 - -public sealed class ExtraModifiers(public val name: String) { - - public sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) { - public object Inline : KotlinOnlyModifiers("inline") - public object Value : KotlinOnlyModifiers("value") - public object Infix : KotlinOnlyModifiers("infix") - public object External : KotlinOnlyModifiers("external") - public object Suspend : KotlinOnlyModifiers("suspend") - public object Reified : KotlinOnlyModifiers("reified") - public object CrossInline : KotlinOnlyModifiers("crossinline") - public object NoInline : KotlinOnlyModifiers("noinline") - public object Override : KotlinOnlyModifiers("override") - public object Data : KotlinOnlyModifiers("data") - public object Const : KotlinOnlyModifiers("const") - public object Inner : KotlinOnlyModifiers("inner") - public object LateInit : KotlinOnlyModifiers("lateinit") - public object Operator : KotlinOnlyModifiers("operator") - public object TailRec : KotlinOnlyModifiers("tailrec") - public object VarArg : KotlinOnlyModifiers("vararg") - public object Fun : KotlinOnlyModifiers("fun") - } - - public sealed class JavaOnlyModifiers(name: String) : ExtraModifiers(name) { - public object Static : JavaOnlyModifiers("static") - public object Native : JavaOnlyModifiers("native") - public object Synchronized : JavaOnlyModifiers("synchronized") - public object StrictFP : JavaOnlyModifiers("strictfp") - public object Transient : JavaOnlyModifiers("transient") - public object Volatile : JavaOnlyModifiers("volatile") - public object Transitive : JavaOnlyModifiers("transitive") - } - - public companion object { - public fun valueOf(str: String): ExtraModifiers = when (str) { - "inline" -> KotlinOnlyModifiers.Inline - "value" -> KotlinOnlyModifiers.Value - "infix" -> KotlinOnlyModifiers.Infix - "external" -> KotlinOnlyModifiers.External - "suspend" -> KotlinOnlyModifiers.Suspend - "reified" -> KotlinOnlyModifiers.Reified - "crossinline" -> KotlinOnlyModifiers.CrossInline - "noinline" -> KotlinOnlyModifiers.NoInline - "override" -> KotlinOnlyModifiers.Override - "data" -> KotlinOnlyModifiers.Data - "const" -> KotlinOnlyModifiers.Const - "inner" -> KotlinOnlyModifiers.Inner - "lateinit" -> KotlinOnlyModifiers.LateInit - "operator" -> KotlinOnlyModifiers.Operator - "tailrec" -> KotlinOnlyModifiers.TailRec - "vararg" -> KotlinOnlyModifiers.VarArg - "static" -> JavaOnlyModifiers.Static - "native" -> JavaOnlyModifiers.Native - "synchronized" -> JavaOnlyModifiers.Synchronized - "strictfp" -> JavaOnlyModifiers.StrictFP - "transient" -> JavaOnlyModifiers.Transient - "volatile" -> JavaOnlyModifiers.Volatile - "transitive" -> JavaOnlyModifiers.Transitive - "fun" -> KotlinOnlyModifiers.Fun - else -> throw IllegalArgumentException("There is no Extra Modifier for given name $str") - } - } -} diff --git a/core/src/main/kotlin/model/jvmName.kt b/core/src/main/kotlin/model/jvmName.kt deleted file mode 100644 index 8fd7ccd9..00000000 --- a/core/src/main/kotlin/model/jvmName.kt +++ /dev/null @@ -1,11 +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.links.DRI - -public fun DRI.isJvmName(): Boolean = packageName == "kotlin.jvm" && classNames == "JvmName" - -public fun Annotations.Annotation.isJvmName(): Boolean = dri.isJvmName() diff --git a/core/src/main/kotlin/model/properties/PropertyContainer.kt b/core/src/main/kotlin/model/properties/PropertyContainer.kt deleted file mode 100644 index 7f5bb2f0..00000000 --- a/core/src/main/kotlin/model/properties/PropertyContainer.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.model.properties - -public data class PropertyContainer internal constructor( - @PublishedApi internal val map: Map, ExtraProperty> -) { - public operator fun plus(prop: ExtraProperty): PropertyContainer = - PropertyContainer(map + (prop.key to prop)) - - // TODO: Add logic for caching calculated properties - public inline operator fun get(key: ExtraProperty.Key): T? = when (val prop = map[key]) { - is T? -> prop - else -> throw ClassCastException("Property for $key stored under not matching key type.") - } - - public inline fun allOfType(): List = map.values.filterIsInstance() - - public fun addAll(extras: Collection>): PropertyContainer = - PropertyContainer(map + extras.map { p -> p.key to p }) - - public operator fun minus(prop: ExtraProperty.Key): PropertyContainer = - PropertyContainer(map.filterNot { it.key == prop }) - - public companion object { - public fun empty(): PropertyContainer = PropertyContainer(emptyMap()) - public fun withAll(vararg extras: ExtraProperty?): PropertyContainer = empty().addAll(extras.filterNotNull()) - public fun withAll(extras: Collection>): PropertyContainer = empty().addAll(extras) - } -} - -public operator fun PropertyContainer.plus(prop: ExtraProperty?): PropertyContainer = - if (prop == null) this else PropertyContainer(map + (prop.key to prop)) - - -public interface WithExtraProperties { - public val extra: PropertyContainer - - public fun withNewExtras(newExtras: PropertyContainer): C -} - -public fun C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties { - val aggregatedExtras: List>> = - (left.extra.map.values + right.extra.map.values) - .groupBy { it.key } - .values - .map { it.distinct() } - - val (unambiguous, toMerge) = aggregatedExtras.partition { it.size == 1 } - - @Suppress("UNCHECKED_CAST") - val strategies: List> = toMerge.map { (l, r) -> - (l.key as ExtraProperty.Key>).mergeStrategyFor(l, r) - } - - strategies.filterIsInstance().firstOrNull()?.error?.invoke() - - val replaces: List> = - strategies.filterIsInstance>().map { it.newProperty } - - val needingFullMerge: List<(preMerged: C, left: C, right: C) -> C> = - strategies.filterIsInstance>().map { it.merger } - - val newExtras = PropertyContainer((unambiguous.flatten() + replaces).associateBy { it.key }) - - return needingFullMerge.fold(withNewExtras(newExtras)) { acc, merger -> merger(acc, left, right) } -} diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt deleted file mode 100644 index ea76dc72..00000000 --- a/core/src/main/kotlin/model/properties/properties.kt +++ /dev/null @@ -1,36 +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.properties - -public interface ExtraProperty { - public interface Key { - public fun mergeStrategyFor(left: T, right: T): MergeStrategy = MergeStrategy.Fail { - throw NotImplementedError("Property merging for $this is not implemented") - } - } - - public val key: Key -} - -public interface CalculatedProperty : ExtraProperty.Key { - public fun calculate(subject: C): T -} - -public sealed class MergeStrategy { - - public class Replace( - public val newProperty: ExtraProperty - ) : MergeStrategy() - - public object Remove : MergeStrategy() - - public class Full( - public val merger: (preMerged: C, left: C, right: C) -> C - ) : MergeStrategy() - - public class Fail( - public val error: () -> Nothing - ) : MergeStrategy() -} diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt deleted file mode 100644 index 96f43205..00000000 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ /dev/null @@ -1,436 +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.pages - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.DisplaySourceSet -import org.jetbrains.dokka.model.WithChildren -import org.jetbrains.dokka.model.properties.PropertyContainer -import org.jetbrains.dokka.model.properties.WithExtraProperties - -public data class DCI(val dri: Set, val kind: Kind) { - override fun toString(): String = "$dri[$kind]" -} - -public interface ContentNode : WithExtraProperties, WithChildren { - public val dci: DCI - public val sourceSets: Set - public val style: Set