diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-11-10 11:46:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 11:46:54 +0100 |
commit | 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch) | |
tree | 1b915207b2b9f61951ddbf0ff2e687efd053d555 /core/src/main/kotlin/model | |
parent | a44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff) | |
download | dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2 dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip |
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing
* Update Gradle to 8.4
* Refactor and simplify convention plugins and build scripts
Fixes #3132
---------
Co-authored-by: Adam <897017+aSemy@users.noreply.github.com>
Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'core/src/main/kotlin/model')
18 files changed, 0 insertions, 1676 deletions
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<DokkaSourceSetID> -) { - public constructor(sourceSetIDs: Iterable<DokkaSourceSetID>) : 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<DokkaSourceSetID> = 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<DokkaSourceSet>.toDisplaySourceSets(): Set<DisplaySourceSet> = - map { it.toDisplaySourceSet() }.toSet() - -@InternalDokkaApi -@Deprecated("Use computeSourceSetIds() and cache its results instead", replaceWith = ReplaceWith("computeSourceSetIds()")) -public val Iterable<DisplaySourceSet>.sourceSetIDs: List<DokkaSourceSetID> get() = this.flatMap { it.sourceSetIDs.all } - -@InternalDokkaApi -public fun Iterable<DisplaySourceSet>.computeSourceSetIds(): Set<DokkaSourceSetID> = - 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<Documentable>, - AnnotationTarget { - public abstract val name: String? - public abstract val dri: DRI - public abstract val documentation: SourceSetDependent<DocumentationNode> - public abstract val sourceSets: Set<DokkaSourceSet> - public abstract val expectPresentInSet: DokkaSourceSet? - abstract override val children: List<Documentable> - - 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<T> = Map<DokkaSourceSet, T> - -public interface WithSources { - public val sources: SourceSetDependent<DocumentableSource> -} - -public interface WithScope { - public val functions: List<DFunction> - public val properties: List<DProperty> - public val classlikes: List<DClasslike> -} - -public interface WithVisibility { - public val visibility: SourceSetDependent<Visibility> -} - -public interface WithType { - public val type: Bound -} - -public interface WithAbstraction { - public val modifier: SourceSetDependent<Modifier> -} - -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<DFunction> -} - -public interface WithGenerics { - public val generics: List<DTypeParameter> -} - -public interface WithSupertypes { - public val supertypes: SourceSetDependent<List<TypeConstructorWithKind>> -} - -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<DPackage>, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet? = null, - override val sourceSets: Set<DokkaSourceSet>, - override val extra: PropertyContainer<DModule> = PropertyContainer.empty() -) : Documentable(), WithExtraProperties<DModule> { - override val dri: DRI = DRI.topLevel - override val children: List<Documentable> - get() = packages - - override fun withNewExtras(newExtras: PropertyContainer<DModule>): DModule = copy(extra = newExtras) -} - -public data class DPackage( - override val dri: DRI, - override val functions: List<DFunction>, - override val properties: List<DProperty>, - override val classlikes: List<DClasslike>, - val typealiases: List<DTypeAlias>, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet? = null, - override val sourceSets: Set<DokkaSourceSet>, - override val extra: PropertyContainer<DPackage> = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties<DPackage> { - - 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<Documentable> = properties + functions + classlikes + typealiases - - override fun withNewExtras(newExtras: PropertyContainer<DPackage>): DPackage = copy(extra = newExtras) -} - -public data class DClass( - override val dri: DRI, - override val name: String, - override val constructors: List<DFunction>, - override val functions: List<DFunction>, - override val properties: List<DProperty>, - override val classlikes: List<DClasslike>, - override val sources: SourceSetDependent<DocumentableSource>, - override val visibility: SourceSetDependent<Visibility>, - override val companion: DObject?, - override val generics: List<DTypeParameter>, - override val supertypes: SourceSetDependent<List<TypeConstructorWithKind>>, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val modifier: SourceSetDependent<Modifier>, - override val sourceSets: Set<DokkaSourceSet>, - override val isExpectActual: Boolean, - override val extra: PropertyContainer<DClass> = PropertyContainer.empty() -) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, - WithExtraProperties<DClass> { - - override val children: List<Documentable> - get() = (functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer<DClass>): DClass = copy(extra = newExtras) -} - -public data class DEnum( - override val dri: DRI, - override val name: String, - val entries: List<DEnumEntry>, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent<DocumentableSource>, - override val functions: List<DFunction>, - override val properties: List<DProperty>, - override val classlikes: List<DClasslike>, - override val visibility: SourceSetDependent<Visibility>, - override val companion: DObject?, - override val constructors: List<DFunction>, - override val supertypes: SourceSetDependent<List<TypeConstructorWithKind>>, - override val sourceSets: Set<DokkaSourceSet>, - override val isExpectActual: Boolean, - override val extra: PropertyContainer<DEnum> = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties<DEnum> { - override val children: List<Documentable> - get() = (entries + functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer<DEnum>): DEnum = copy(extra = newExtras) -} - -public data class DEnumEntry( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val functions: List<DFunction>, - override val properties: List<DProperty>, - override val classlikes: List<DClasslike>, - override val sourceSets: Set<DokkaSourceSet>, - override val extra: PropertyContainer<DEnumEntry> = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties<DEnumEntry> { - override val children: List<Documentable> - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer<DEnumEntry>): DEnumEntry = copy(extra = newExtras) -} - -public data class DFunction( - override val dri: DRI, - override val name: String, - val isConstructor: Boolean, - val parameters: List<DParameter>, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent<DocumentableSource>, - override val visibility: SourceSetDependent<Visibility>, - override val type: Bound, - override val generics: List<DTypeParameter>, - override val receiver: DParameter?, - override val modifier: SourceSetDependent<Modifier>, - override val sourceSets: Set<DokkaSourceSet>, - override val isExpectActual: Boolean, - override val extra: PropertyContainer<DFunction> = PropertyContainer.empty() -) : Documentable(), Callable, WithGenerics, WithExtraProperties<DFunction> { - override val children: List<Documentable> - get() = parameters - - override fun withNewExtras(newExtras: PropertyContainer<DFunction>): DFunction = copy(extra = newExtras) -} - -public data class DInterface( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent<DocumentableSource>, - override val functions: List<DFunction>, - override val properties: List<DProperty>, - override val classlikes: List<DClasslike>, - override val visibility: SourceSetDependent<Visibility>, - override val companion: DObject?, - override val generics: List<DTypeParameter>, - override val supertypes: SourceSetDependent<List<TypeConstructorWithKind>>, - override val sourceSets: Set<DokkaSourceSet>, - override val isExpectActual: Boolean, - override val extra: PropertyContainer<DInterface> = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties<DInterface> { - override val children: List<Documentable> - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer<DInterface>): DInterface = copy(extra = newExtras) -} - -public data class DObject( - override val name: String?, - override val dri: DRI, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent<DocumentableSource>, - override val functions: List<DFunction>, - override val properties: List<DProperty>, - override val classlikes: List<DClasslike>, - override val visibility: SourceSetDependent<Visibility>, - override val supertypes: SourceSetDependent<List<TypeConstructorWithKind>>, - override val sourceSets: Set<DokkaSourceSet>, - override val isExpectActual: Boolean, - override val extra: PropertyContainer<DObject> = PropertyContainer.empty() -) : DClasslike(), WithSupertypes, WithExtraProperties<DObject> { - override val children: List<Documentable> - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer<DObject>): DObject = copy(extra = newExtras) -} - -public data class DAnnotation( - override val name: String, - override val dri: DRI, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent<DocumentableSource>, - override val functions: List<DFunction>, - override val properties: List<DProperty>, - override val classlikes: List<DClasslike>, - override val visibility: SourceSetDependent<Visibility>, - override val companion: DObject?, - override val constructors: List<DFunction>, - override val generics: List<DTypeParameter>, - override val sourceSets: Set<DokkaSourceSet>, - override val isExpectActual: Boolean, - override val extra: PropertyContainer<DAnnotation> = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties<DAnnotation>, WithGenerics { - override val children: List<Documentable> - get() = (functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer<DAnnotation>): DAnnotation = copy(extra = newExtras) -} - -public data class DProperty( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent<DocumentableSource>, - override val visibility: SourceSetDependent<Visibility>, - override val type: Bound, - override val receiver: DParameter?, - val setter: DFunction?, - val getter: DFunction?, - override val modifier: SourceSetDependent<Modifier>, - override val sourceSets: Set<DokkaSourceSet>, - override val generics: List<DTypeParameter>, - override val isExpectActual: Boolean, - override val extra: PropertyContainer<DProperty> = PropertyContainer.empty() -) : Documentable(), Callable, WithExtraProperties<DProperty>, WithGenerics { - override val children: List<Nothing> - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer<DProperty>): 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<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val type: Bound, - override val sourceSets: Set<DokkaSourceSet>, - override val extra: PropertyContainer<DParameter> = PropertyContainer.empty() -) : Documentable(), WithExtraProperties<DParameter>, WithType { - override val children: List<Nothing> - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer<DParameter>): DParameter = copy(extra = newExtras) -} - -public data class DTypeParameter( - val variantTypeParameter: Variance<TypeParameter>, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - val bounds: List<Bound>, - override val sourceSets: Set<DokkaSourceSet>, - override val extra: PropertyContainer<DTypeParameter> = PropertyContainer.empty() -) : Documentable(), WithExtraProperties<DTypeParameter> { - - public constructor( - dri: DRI, - name: String, - presentableName: String?, - documentation: SourceSetDependent<DocumentationNode>, - expectPresentInSet: DokkaSourceSet?, - bounds: List<Bound>, - sourceSets: Set<DokkaSourceSet>, - extra: PropertyContainer<DTypeParameter> = 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<Nothing> - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer<DTypeParameter>): DTypeParameter = copy(extra = newExtras) -} - -public data class DTypeAlias( - override val dri: DRI, - override val name: String, - override val type: Bound, - val underlyingType: SourceSetDependent<Bound>, - override val visibility: SourceSetDependent<Visibility>, - override val documentation: SourceSetDependent<DocumentationNode>, - override val expectPresentInSet: DokkaSourceSet?, - override val sourceSets: Set<DokkaSourceSet>, - override val generics: List<DTypeParameter>, - override val sources: SourceSetDependent<DocumentableSource>, - override val extra: PropertyContainer<DTypeAlias> = PropertyContainer.empty() -) : Documentable(), WithType, WithVisibility, WithExtraProperties<DTypeAlias>, WithGenerics, WithSources { - override val children: List<Nothing> - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer<DTypeAlias>): 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<TypeParameter> = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties<TypeParameter> { - override fun withNewExtras(newExtras: PropertyContainer<TypeParameter>): TypeParameter = - copy(extra = extra) -} - -public sealed class TypeConstructor : Bound(), AnnotationTarget { - public abstract val dri: DRI - public abstract val projections: List<Projection> - public abstract val presentableName: String? -} - -public data class GenericTypeConstructor( - override val dri: DRI, - override val projections: List<Projection>, - override val presentableName: String? = null, - override val extra: PropertyContainer<GenericTypeConstructor> = PropertyContainer.empty() -) : TypeConstructor(), WithExtraProperties<GenericTypeConstructor> { - override fun withNewExtras(newExtras: PropertyContainer<GenericTypeConstructor>): GenericTypeConstructor = - copy(extra = newExtras) -} - -public data class FunctionalTypeConstructor( - override val dri: DRI, - override val projections: List<Projection>, - val isExtensionFunction: Boolean = false, - val isSuspendable: Boolean = false, - override val presentableName: String? = null, - override val extra: PropertyContainer<FunctionalTypeConstructor> = PropertyContainer.empty(), -) : TypeConstructor(), WithExtraProperties<FunctionalTypeConstructor> { - override fun withNewExtras(newExtras: PropertyContainer<FunctionalTypeConstructor>): FunctionalTypeConstructor = - copy(extra = newExtras) -} - -// kotlin.annotation.AnnotationTarget.TYPEALIAS -public data class TypeAliased( - val typeAlias: Bound, - val inner: Bound, - override val extra: PropertyContainer<TypeAliased> = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties<TypeAliased> { - override fun withNewExtras(newExtras: PropertyContainer<TypeAliased>): TypeAliased = - copy(extra = newExtras) -} - -public data class PrimitiveJavaType( - val name: String, - override val extra: PropertyContainer<PrimitiveJavaType> = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties<PrimitiveJavaType> { - override fun withNewExtras(newExtras: PropertyContainer<PrimitiveJavaType>): PrimitiveJavaType = - copy(extra = newExtras) -} - -public data class JavaObject(override val extra: PropertyContainer<JavaObject> = PropertyContainer.empty()) : - Bound(), AnnotationTarget, WithExtraProperties<JavaObject> { - override fun withNewExtras(newExtras: PropertyContainer<JavaObject>): JavaObject = - copy(extra = newExtras) -} - -public data class UnresolvedBound( - val name: String, - override val extra: PropertyContainer<UnresolvedBound> = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties<UnresolvedBound> { - override fun withNewExtras(newExtras: PropertyContainer<UnresolvedBound>): 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<out T : Bound> : Projection() { - public abstract val inner: T -} - -public data class Covariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString(): String = "out" -} - -public data class Contravariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString(): String = "in" -} - -public data class Invariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString(): String = "" -} - -public object Star : Projection() - -public object Void : Bound() -public object Dynamic : Bound() - -public fun Variance<TypeParameter>.withDri(dri: DRI): Variance<TypeParameter> = 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 <T> SourceSetDependent<T>?.orEmpty(): SourceSetDependent<T> = 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<out T> { - public val children: List<T> -} - -public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(): T? = - children.filterIsInstance<T>().firstOrNull() - -public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = - children.filterIsInstance<T>().firstOrNull(predicate) - -public inline fun <reified T> WithChildren<*>.firstChildOfType(): T = - children.filterIsInstance<T>().first() - -public inline fun <reified T> WithChildren<*>.childrenOfType(): List<T> = - children.filterIsInstance<T>() - -public inline fun <reified T> WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = - children.filterIsInstance<T>().first(predicate) - -public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T where T : WithChildren<*> { - return withDescendants().filterIsInstance<T>().first() -} - -public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType( - predicate: (T) -> Boolean -): T where T : WithChildren<*> = withDescendants().filterIsInstance<T>().first(predicate) - - -public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { - return withDescendants().filterIsInstance<T>().firstOrNull() -} - -public fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - yieldAll(child.withDescendants()) - } - } -} - -@JvmName("withDescendantsProjection") -public fun WithChildren<*>.withDescendants(): Sequence<Any?> { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - if (child is WithChildren<*>) { - yieldAll(child.withDescendants()) - } - } - } -} - -@JvmName("withDescendantsAny") -public fun WithChildren<Any>.withDescendants(): Sequence<Any> { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - if (child is WithChildren<*>) { - yieldAll(child.withDescendants().filterNotNull()) - } - } - } -} - -public fun <T> T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren<T> = if (predicate(this)) { - this -} else { - children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() -} - -public fun <T : WithChildren<T>> 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<Set<ExtraModifiers>> -) : ExtraProperty<Documentable> { - - public companion object : ExtraProperty.Key<Documentable, AdditionalModifiers> { - override fun mergeStrategyFor( - left: AdditionalModifiers, - right: AdditionalModifiers - ): MergeStrategy<Documentable> = 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<Documentable, *> = AdditionalModifiers -} - -public fun SourceSetDependent<Set<ExtraModifiers>>.toAdditionalModifiers(): AdditionalModifiers = AdditionalModifiers(this) - -public data class Annotations( - private val myContent: SourceSetDependent<List<Annotation>> -) : ExtraProperty<AnnotationTarget> { - public companion object : ExtraProperty.Key<AnnotationTarget, Annotations> { - override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy<AnnotationTarget> = - MergeStrategy.Replace(Annotations(left.myContent + right.myContent)) - } - - override val key: ExtraProperty.Key<AnnotationTarget, *> = Annotations - - public data class Annotation( - val dri: DRI, - val params: Map<String, AnnotationParameterValue>, - 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<List<Annotation>> - get() = myContent - - val directAnnotations: SourceSetDependent<List<Annotation>> = annotationsByScope(AnnotationScope.DIRECT) - - val fileLevelAnnotations: SourceSetDependent<List<Annotation>> = annotationsByScope(AnnotationScope.FILE) - - private fun annotationsByScope(scope: AnnotationScope): SourceSetDependent<List<Annotation>> = - 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<List<Annotations.Annotation>>.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>) : 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<DFunction>, ExtraProperty.Key<DFunction, PrimaryConstructorExtra> { - override val key: ExtraProperty.Key<DFunction, *> = this -} - -public data class ActualTypealias( - val typeAlias: DTypeAlias -) : ExtraProperty<DClasslike> { - - @Suppress("unused") - @Deprecated(message = "It can be removed soon. Use [typeAlias.underlyingType]", ReplaceWith("this.typeAlias.underlyingType")) - val underlyingType: SourceSetDependent<Bound> - get() = typeAlias.underlyingType - - public companion object : ExtraProperty.Key<DClasslike, ActualTypealias> { - override fun mergeStrategyFor( - left: ActualTypealias, - right: ActualTypealias - ): MergeStrategy<DClasslike> = MergeStrategy.Fail { - throw IllegalStateException("Adding [ActualTypealias] should be after merging all documentables") - } - } - - override val key: ExtraProperty.Key<DClasslike, ActualTypealias> = 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<AncestryNode>, -) { - public fun allImplementedInterfaces(): List<TypeConstructor> { - fun traverseInterfaces(ancestry: AncestryNode): List<TypeConstructor> = - 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<Expression> -): ExtraProperty<Documentable> { - - @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<Documentable, DefaultValue> { - override fun mergeStrategyFor(left: DefaultValue, right: DefaultValue): MergeStrategy<Documentable> = - MergeStrategy.Replace(DefaultValue(left.expression + right.expression)) - - } - - override val key: ExtraProperty.Key<Documentable, *> - 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<DocTag> { - public abstract val params: Map<String, String> - - public companion object { - public fun contentTypeParam(type: String): Map<String, String> = mapOf("content-type" to type) - } -} - -public data class A( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Big( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class B( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class BlockQuote( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public object Br : DocTag() { - override val children: List<DocTag> = emptyList() - override val params: Map<String, String> = emptyMap() -} - -public data class Cite( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public sealed class Code : DocTag() - -public data class CodeInline( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : Code() - -public data class CodeBlock( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : Code() - -public data class CustomDocTag( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap(), - val name: String -) : DocTag() - -public data class Dd( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Dfn( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Dir( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Div( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Dl( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class DocumentationLink( - val dri: DRI, - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Dt( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Em( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Font( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Footer( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Frame( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class FrameSet( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class H1( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class H2( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class H3( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class H4( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class H5( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class H6( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Head( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Header( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public object HorizontalRule : DocTag() { - override val children: List<DocTag> = emptyList() - override val params: Map<String, String> = emptyMap() -} - -public data class Html( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class I( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class IFrame( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Img( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Index( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Input( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Li( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Link( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Listing( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Main( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Menu( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Meta( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Nav( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class NoFrames( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class NoScript( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Ol( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class P( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Pre( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Script( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Section( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Small( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Span( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Strikethrough( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Strong( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Sub( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Sup( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Table( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Text( - val body: String = "", - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class TBody( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Td( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class TFoot( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Th( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class THead( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Title( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Tr( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Tt( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class U( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Ul( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Var( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = emptyMap() -) : DocTag() - -public data class Caption( - override val children: List<DocTag> = emptyList(), - override val params: Map<String, String> = 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<TagWrapper>): WithChildren<TagWrapper> 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<DocTag> { - public abstract val root: DocTag - - override val children: List<DocTag> - 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<DRI?>) : ExtraProperty<Documentable> { - public companion object : ExtraProperty.Key<Documentable, InheritedMember> { - override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember): MergeStrategy<Documentable> = MergeStrategy.Replace( - InheritedMember(left.inheritedFrom + right.inheritedFrom) - ) - } - - public fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null - - override val key: ExtraProperty.Key<Documentable, *> = InheritedMember -} - -public data class ImplementedInterfaces(val interfaces: SourceSetDependent<List<TypeConstructor>>) : ExtraProperty<Documentable> { - public companion object : ExtraProperty.Key<Documentable, ImplementedInterfaces> { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces): MergeStrategy<Documentable> = - MergeStrategy.Replace(ImplementedInterfaces(left.interfaces + right.interfaces)) - } - - override val key: ExtraProperty.Key<Documentable, *> = ImplementedInterfaces -} - -public data class ExceptionInSupertypes(val exceptions: SourceSetDependent<List<TypeConstructor>>): ExtraProperty<Documentable> { - public companion object : ExtraProperty.Key<Documentable, ExceptionInSupertypes> { - override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes): MergeStrategy<Documentable> = - MergeStrategy.Replace(ExceptionInSupertypes(left.exceptions + right.exceptions)) - } - - override val key: ExtraProperty.Key<Documentable, *> = ExceptionInSupertypes -} - -public object ObviousMember : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { - override val key: ExtraProperty.Key<Documentable, *> = 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<DProperty>, ExtraProperty.Key<DProperty, IsVar> { - override val key: ExtraProperty.Key<DProperty, *> = this -} - -public data class IsAlsoParameter(val inSourceSets: List<DokkaSourceSet>) : ExtraProperty<DProperty> { - public companion object : ExtraProperty.Key<DProperty, IsAlsoParameter> { - override fun mergeStrategyFor(left: IsAlsoParameter, right: IsAlsoParameter): MergeStrategy<DProperty> = - MergeStrategy.Replace(IsAlsoParameter(left.inSourceSets + right.inSourceSets)) - } - - override val key: ExtraProperty.Key<DProperty, *> = IsAlsoParameter -} - -public data class CheckedExceptions(val exceptions: SourceSetDependent<List<DRI>>) : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { - public companion object : ExtraProperty.Key<Documentable, CheckedExceptions> { - override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions): MergeStrategy<Documentable> = - MergeStrategy.Replace(CheckedExceptions(left.exceptions + right.exceptions)) - } - override val key: ExtraProperty.Key<Documentable, *> = 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 <T> SourceSetDependent<T>.filtered(sourceSets: Set<DokkaSourceSet>): SourceSetDependent<T> = filter { it.key in sourceSets } -public fun DokkaSourceSet?.filtered(sourceSets: Set<DokkaSourceSet>): DokkaSourceSet? = takeIf { this in sourceSets } - -public fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>): 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<C : Any> internal constructor( - @PublishedApi internal val map: Map<ExtraProperty.Key<C, *>, ExtraProperty<C>> -) { - public operator fun <D : C> plus(prop: ExtraProperty<D>): PropertyContainer<D> = - PropertyContainer(map + (prop.key to prop)) - - // TODO: Add logic for caching calculated properties - public inline operator fun <reified T : Any> get(key: ExtraProperty.Key<C, T>): T? = when (val prop = map[key]) { - is T? -> prop - else -> throw ClassCastException("Property for $key stored under not matching key type.") - } - - public inline fun <reified T : Any> allOfType(): List<T> = map.values.filterIsInstance<T>() - - public fun <D : C> addAll(extras: Collection<ExtraProperty<D>>): PropertyContainer<D> = - PropertyContainer(map + extras.map { p -> p.key to p }) - - public operator fun <D : C> minus(prop: ExtraProperty.Key<C, *>): PropertyContainer<D> = - PropertyContainer(map.filterNot { it.key == prop }) - - public companion object { - public fun <T : Any> empty(): PropertyContainer<T> = PropertyContainer(emptyMap()) - public fun <T : Any> withAll(vararg extras: ExtraProperty<T>?): PropertyContainer<T> = empty<T>().addAll(extras.filterNotNull()) - public fun <T : Any> withAll(extras: Collection<ExtraProperty<T>>): PropertyContainer<T> = empty<T>().addAll(extras) - } -} - -public operator fun <D: Any> PropertyContainer<D>.plus(prop: ExtraProperty<D>?): PropertyContainer<D> = - if (prop == null) this else PropertyContainer(map + (prop.key to prop)) - - -public interface WithExtraProperties<C : Any> { - public val extra: PropertyContainer<C> - - public fun withNewExtras(newExtras: PropertyContainer<C>): C -} - -public fun <C> C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties<C> { - val aggregatedExtras: List<List<ExtraProperty<C>>> = - (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<MergeStrategy<C>> = toMerge.map { (l, r) -> - (l.key as ExtraProperty.Key<C, ExtraProperty<C>>).mergeStrategyFor(l, r) - } - - strategies.filterIsInstance<MergeStrategy.Fail>().firstOrNull()?.error?.invoke() - - val replaces: List<ExtraProperty<C>> = - strategies.filterIsInstance<MergeStrategy.Replace<C>>().map { it.newProperty } - - val needingFullMerge: List<(preMerged: C, left: C, right: C) -> C> = - strategies.filterIsInstance<MergeStrategy.Full<C>>().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<in C : Any> { - public interface Key<in C : Any, T : Any> { - public fun mergeStrategyFor(left: T, right: T): MergeStrategy<C> = MergeStrategy.Fail { - throw NotImplementedError("Property merging for $this is not implemented") - } - } - - public val key: Key<C, *> -} - -public interface CalculatedProperty<in C : Any, T : Any> : ExtraProperty.Key<C, T> { - public fun calculate(subject: C): T -} - -public sealed class MergeStrategy<in C> { - - public class Replace<in C : Any>( - public val newProperty: ExtraProperty<C> - ) : MergeStrategy<C>() - - public object Remove : MergeStrategy<Any>() - - public class Full<C : Any>( - public val merger: (preMerged: C, left: C, right: C) -> C - ) : MergeStrategy<C>() - - public class Fail( - public val error: () -> Nothing - ) : MergeStrategy<Any>() -} |