diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-08-31 20:16:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-31 20:16:01 +0200 |
commit | 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch) | |
tree | 66f6d6f089a93b863bf1144666491eca6729ad05 /core/src/main/kotlin/model | |
parent | 6a181a7a2b03ec263788d137610e86937a57d434 (diff) | |
download | dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2 dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip |
Enable explicit API mode (#3139)
Diffstat (limited to 'core/src/main/kotlin/model')
-rw-r--r-- | core/src/main/kotlin/model/CompositeSourceSetID.kt | 6 | ||||
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 238 | ||||
-rw-r--r-- | core/src/main/kotlin/model/JvmField.kt | 8 | ||||
-rw-r--r-- | core/src/main/kotlin/model/WithChildren.kt | 30 | ||||
-rw-r--r-- | core/src/main/kotlin/model/additionalExtras.kt | 68 | ||||
-rw-r--r-- | core/src/main/kotlin/model/ancestryNode.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/model/classKinds.kt | 6 | ||||
-rw-r--r-- | core/src/main/kotlin/model/defaultValues.kt | 23 | ||||
-rw-r--r-- | core/src/main/kotlin/model/doc/DocTag.kt | 163 | ||||
-rw-r--r-- | core/src/main/kotlin/model/doc/DocumentationNode.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/model/doc/TagWrapper.kt | 39 | ||||
-rw-r--r-- | core/src/main/kotlin/model/documentableProperties.kt | 34 | ||||
-rw-r--r-- | core/src/main/kotlin/model/documentableUtils.kt | 8 | ||||
-rw-r--r-- | core/src/main/kotlin/model/extraModifiers.kt | 58 | ||||
-rw-r--r-- | core/src/main/kotlin/model/jvmName.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/model/properties/PropertyContainer.kt | 31 | ||||
-rw-r--r-- | core/src/main/kotlin/model/properties/properties.kt | 32 |
17 files changed, 394 insertions, 360 deletions
diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt index 36318633..af7d1a5d 100644 --- a/core/src/main/kotlin/model/CompositeSourceSetID.kt +++ b/core/src/main/kotlin/model/CompositeSourceSetID.kt @@ -32,15 +32,15 @@ public data class CompositeSourceSetID( public val all: Set<DokkaSourceSetID> = setOf(merged, *children.toTypedArray()) - operator fun contains(sourceSetId: DokkaSourceSetID): Boolean { + public operator fun contains(sourceSetId: DokkaSourceSetID): Boolean { return sourceSetId in all } - operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean { + public operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean { return sourceSet.sourceSetID in this } - operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID { + public operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID { return copy(children = children + other) } } diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index d96b051c..c6109f47 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -10,92 +10,95 @@ import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties -interface AnnotationTarget +public interface AnnotationTarget -abstract class Documentable : WithChildren<Documentable>, +public abstract class Documentable : WithChildren<Documentable>, AnnotationTarget { - abstract val name: String? - abstract val dri: DRI - abstract val documentation: SourceSetDependent<DocumentationNode> - abstract val sourceSets: Set<DokkaSourceSet> - abstract val expectPresentInSet: DokkaSourceSet? + 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?) = + 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() = dri.hashCode() + override fun hashCode(): Int = dri.hashCode() } -typealias SourceSetDependent<T> = Map<DokkaSourceSet, T> +public typealias SourceSetDependent<T> = Map<DokkaSourceSet, T> -interface WithSources { - val sources: SourceSetDependent<DocumentableSource> +public interface WithSources { + public val sources: SourceSetDependent<DocumentableSource> } -interface WithScope { - val functions: List<DFunction> - val properties: List<DProperty> - val classlikes: List<DClasslike> +public interface WithScope { + public val functions: List<DFunction> + public val properties: List<DProperty> + public val classlikes: List<DClasslike> } -interface WithVisibility { - val visibility: SourceSetDependent<Visibility> +public interface WithVisibility { + public val visibility: SourceSetDependent<Visibility> } -interface WithType { - val type: Bound +public interface WithType { + public val type: Bound } -interface WithAbstraction { - val modifier: SourceSetDependent<Modifier> +public interface WithAbstraction { + public val modifier: SourceSetDependent<Modifier> } -sealed class Modifier(val name: String) -sealed class KotlinModifier(name: String) : Modifier(name) { - object Abstract : KotlinModifier("abstract") - object Open : KotlinModifier("open") - object Final : KotlinModifier("final") - object Sealed : KotlinModifier("sealed") - object Empty : KotlinModifier("") +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("") } -sealed class JavaModifier(name: String) : Modifier(name) { - object Abstract : JavaModifier("abstract") - object Final : JavaModifier("final") - object Empty : JavaModifier("") +public sealed class JavaModifier(name: String) : Modifier(name) { + public object Abstract : JavaModifier("abstract") + public object Final : JavaModifier("final") + public object Empty : JavaModifier("") } -interface WithCompanion { - val companion: DObject? +public interface WithCompanion { + public val companion: DObject? } -interface WithConstructors { - val constructors: List<DFunction> +public interface WithConstructors { + public val constructors: List<DFunction> } -interface WithGenerics { - val generics: List<DTypeParameter> +public interface WithGenerics { + public val generics: List<DTypeParameter> } -interface WithSupertypes { - val supertypes: SourceSetDependent<List<TypeConstructorWithKind>> +public interface WithSupertypes { + public val supertypes: SourceSetDependent<List<TypeConstructorWithKind>> } -interface WithIsExpectActual { - val isExpectActual: Boolean +public interface WithIsExpectActual { + public val isExpectActual: Boolean } -interface Callable : WithVisibility, WithType, WithAbstraction, WithSources, WithIsExpectActual { - val receiver: DParameter? +public interface Callable : WithVisibility, WithType, WithAbstraction, WithSources, WithIsExpectActual { + public val receiver: DParameter? } -sealed class DClasslike : Documentable(), WithScope, WithVisibility, WithSources, WithIsExpectActual +public sealed class DClasslike : Documentable(), WithScope, WithVisibility, WithSources, WithIsExpectActual -data class DModule( +public data class DModule( override val name: String, val packages: List<DPackage>, override val documentation: SourceSetDependent<DocumentationNode>, @@ -107,10 +110,10 @@ data class DModule( override val children: List<Documentable> get() = packages - override fun withNewExtras(newExtras: PropertyContainer<DModule>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DModule>): DModule = copy(extra = newExtras) } -data class DPackage( +public data class DPackage( override val dri: DRI, override val functions: List<DFunction>, override val properties: List<DProperty>, @@ -134,10 +137,10 @@ data class DPackage( override val children: List<Documentable> = properties + functions + classlikes + typealiases - override fun withNewExtras(newExtras: PropertyContainer<DPackage>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DPackage>): DPackage = copy(extra = newExtras) } -data class DClass( +public data class DClass( override val dri: DRI, override val name: String, override val constructors: List<DFunction>, @@ -161,10 +164,10 @@ data class DClass( override val children: List<Documentable> get() = (functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer<DClass>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DClass>): DClass = copy(extra = newExtras) } -data class DEnum( +public data class DEnum( override val dri: DRI, override val name: String, val entries: List<DEnumEntry>, @@ -185,10 +188,10 @@ data class DEnum( override val children: List<Documentable> get() = (entries + functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer<DEnum>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DEnum>): DEnum = copy(extra = newExtras) } -data class DEnumEntry( +public data class DEnumEntry( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, @@ -202,10 +205,10 @@ data class DEnumEntry( override val children: List<Documentable> get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer<DEnumEntry>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DEnumEntry>): DEnumEntry = copy(extra = newExtras) } -data class DFunction( +public data class DFunction( override val dri: DRI, override val name: String, val isConstructor: Boolean, @@ -225,10 +228,10 @@ data class DFunction( override val children: List<Documentable> get() = parameters - override fun withNewExtras(newExtras: PropertyContainer<DFunction>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DFunction>): DFunction = copy(extra = newExtras) } -data class DInterface( +public data class DInterface( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, @@ -248,10 +251,10 @@ data class DInterface( override val children: List<Documentable> get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer<DInterface>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DInterface>): DInterface = copy(extra = newExtras) } -data class DObject( +public data class DObject( override val name: String?, override val dri: DRI, override val documentation: SourceSetDependent<DocumentationNode>, @@ -269,10 +272,10 @@ data class DObject( override val children: List<Documentable> get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer<DObject>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DObject>): DObject = copy(extra = newExtras) } -data class DAnnotation( +public data class DAnnotation( override val name: String, override val dri: DRI, override val documentation: SourceSetDependent<DocumentationNode>, @@ -292,10 +295,10 @@ data class DAnnotation( override val children: List<Documentable> get() = (functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer<DAnnotation>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DAnnotation>): DAnnotation = copy(extra = newExtras) } -data class DProperty( +public data class DProperty( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, @@ -315,11 +318,11 @@ data class DProperty( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DProperty>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DProperty>): DProperty = copy(extra = newExtras) } // TODO: treat named Parameters and receivers differently -data class DParameter( +public data class DParameter( override val dri: DRI, override val name: String?, override val documentation: SourceSetDependent<DocumentationNode>, @@ -331,10 +334,10 @@ data class DParameter( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DParameter>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DParameter>): DParameter = copy(extra = newExtras) } -data class DTypeParameter( +public data class DTypeParameter( val variantTypeParameter: Variance<TypeParameter>, override val documentation: SourceSetDependent<DocumentationNode>, override val expectPresentInSet: DokkaSourceSet?, @@ -343,7 +346,7 @@ data class DTypeParameter( override val extra: PropertyContainer<DTypeParameter> = PropertyContainer.empty() ) : Documentable(), WithExtraProperties<DTypeParameter> { - constructor( + public constructor( dri: DRI, name: String, presentableName: String?, @@ -367,10 +370,10 @@ data class DTypeParameter( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DTypeParameter>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DTypeParameter>): DTypeParameter = copy(extra = newExtras) } -data class DTypeAlias( +public data class DTypeAlias( override val dri: DRI, override val name: String, override val type: Bound, @@ -386,12 +389,12 @@ data class DTypeAlias( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DTypeAlias>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DTypeAlias>): DTypeAlias = copy(extra = newExtras) } -sealed class Projection -sealed class Bound : Projection() -data class TypeParameter( +public sealed class Projection +public sealed class Bound : Projection() +public data class TypeParameter( val dri: DRI, val name: String, val presentableName: String? = null, @@ -401,13 +404,13 @@ data class TypeParameter( copy(extra = extra) } -sealed class TypeConstructor : Bound(), AnnotationTarget { - abstract val dri: DRI - abstract val projections: List<Projection> - abstract val presentableName: String? +public sealed class TypeConstructor : Bound(), AnnotationTarget { + public abstract val dri: DRI + public abstract val projections: List<Projection> + public abstract val presentableName: String? } -data class GenericTypeConstructor( +public data class GenericTypeConstructor( override val dri: DRI, override val projections: List<Projection>, override val presentableName: String? = null, @@ -417,7 +420,7 @@ data class GenericTypeConstructor( copy(extra = newExtras) } -data class FunctionalTypeConstructor( +public data class FunctionalTypeConstructor( override val dri: DRI, override val projections: List<Projection>, val isExtensionFunction: Boolean = false, @@ -430,7 +433,7 @@ data class FunctionalTypeConstructor( } // kotlin.annotation.AnnotationTarget.TYPEALIAS -data class TypeAliased( +public data class TypeAliased( val typeAlias: Bound, val inner: Bound, override val extra: PropertyContainer<TypeAliased> = PropertyContainer.empty() @@ -439,7 +442,7 @@ data class TypeAliased( copy(extra = newExtras) } -data class PrimitiveJavaType( +public data class PrimitiveJavaType( val name: String, override val extra: PropertyContainer<PrimitiveJavaType> = PropertyContainer.empty() ) : Bound(), AnnotationTarget, WithExtraProperties<PrimitiveJavaType> { @@ -447,13 +450,13 @@ data class PrimitiveJavaType( copy(extra = newExtras) } -data class JavaObject(override val extra: PropertyContainer<JavaObject> = PropertyContainer.empty()) : +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) } -data class UnresolvedBound( +public data class UnresolvedBound( val name: String, override val extra: PropertyContainer<UnresolvedBound> = PropertyContainer.empty() ) : Bound(), AnnotationTarget, WithExtraProperties<UnresolvedBound> { @@ -462,66 +465,67 @@ data class UnresolvedBound( } // The following Projections are not AnnotationTargets; they cannot be annotated. -data class Nullable(val inner: Bound) : Bound() +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) */ -data class DefinitelyNonNullable(val inner: Bound) : Bound() +public data class DefinitelyNonNullable(val inner: Bound) : Bound() -sealed class Variance<out T : Bound> : Projection() { - abstract val inner: T +public sealed class Variance<out T : Bound> : Projection() { + public abstract val inner: T } -data class Covariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString() = "out" +public data class Covariance<out T : Bound>(override val inner: T) : Variance<T>() { + override fun toString(): String = "out" } -data class Contravariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString() = "in" +public data class Contravariance<out T : Bound>(override val inner: T) : Variance<T>() { + override fun toString(): String = "in" } -data class Invariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString() = "" +public data class Invariance<out T : Bound>(override val inner: T) : Variance<T>() { + override fun toString(): String = "" } -object Star : Projection() +public object Star : Projection() -object Void : Bound() -object Dynamic : Bound() +public object Void : Bound() +public object Dynamic : Bound() -fun Variance<TypeParameter>.withDri(dri: DRI) = when (this) { +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)) } -fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = +public fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = if (predicate(this)) { this } else { this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() } -sealed class Visibility(val name: String) -sealed class KotlinVisibility(name: String) : Visibility(name) { - object Public : KotlinVisibility("public") - object Private : KotlinVisibility("private") - object Protected : KotlinVisibility("protected") - object Internal : KotlinVisibility("internal") +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") } -sealed class JavaVisibility(name: String) : Visibility(name) { - object Public : JavaVisibility("public") - object Private : JavaVisibility("private") - object Protected : JavaVisibility("protected") - object Default : JavaVisibility("") +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("") } -fun <T> SourceSetDependent<T>?.orEmpty(): SourceSetDependent<T> = this ?: emptyMap() +public fun <T> SourceSetDependent<T>?.orEmpty(): SourceSetDependent<T> = this ?: emptyMap() -interface DocumentableSource { - val path: String +public interface DocumentableSource { + public val path: String /** * Computes the first line number of the documentable's declaration/signature/identifier. @@ -530,7 +534,7 @@ interface DocumentableSource { * * May return null if the sources could not be found - for example, for synthetic/generated declarations. */ - fun computeLineNumber(): Int? + public fun computeLineNumber(): Int? } -data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind) +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 index 38829ef5..a2b641c9 100644 --- a/core/src/main/kotlin/model/JvmField.kt +++ b/core/src/main/kotlin/model/JvmField.kt @@ -6,9 +6,9 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.links.DRI -const val JVM_FIELD_PACKAGE_NAME = "kotlin.jvm" -const val JVM_FIELD_CLASS_NAMES = "JvmField" +public const val JVM_FIELD_PACKAGE_NAME: String = "kotlin.jvm" +public const val JVM_FIELD_CLASS_NAMES: String = "JvmField" -fun DRI.isJvmField(): Boolean = packageName == JVM_FIELD_PACKAGE_NAME && classNames == JVM_FIELD_CLASS_NAMES +public fun DRI.isJvmField(): Boolean = packageName == JVM_FIELD_PACKAGE_NAME && classNames == JVM_FIELD_CLASS_NAMES -fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmField() +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 index 01e69fd0..f73a5aa0 100644 --- a/core/src/main/kotlin/model/WithChildren.kt +++ b/core/src/main/kotlin/model/WithChildren.kt @@ -4,39 +4,39 @@ package org.jetbrains.dokka.model -interface WithChildren<out T> { - val children: List<T> +public interface WithChildren<out T> { + public val children: List<T> } -inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(): T? = +public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(): T? = children.filterIsInstance<T>().firstOrNull() -inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = +public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = children.filterIsInstance<T>().firstOrNull(predicate) -inline fun <reified T> WithChildren<*>.firstChildOfType(): T = +public inline fun <reified T> WithChildren<*>.firstChildOfType(): T = children.filterIsInstance<T>().first() -inline fun <reified T> WithChildren<*>.childrenOfType(): List<T> = +public inline fun <reified T> WithChildren<*>.childrenOfType(): List<T> = children.filterIsInstance<T>() -inline fun <reified T> WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = +public inline fun <reified T> WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = children.filterIsInstance<T>().first(predicate) -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T where T : WithChildren<*> { +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T where T : WithChildren<*> { return withDescendants().filterIsInstance<T>().first() } -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType( +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType( predicate: (T) -> Boolean ): T where T : WithChildren<*> = withDescendants().filterIsInstance<T>().first(predicate) -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { return withDescendants().filterIsInstance<T>().firstOrNull() } -fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { +public fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -46,7 +46,7 @@ fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { } @JvmName("withDescendantsProjection") -fun WithChildren<*>.withDescendants(): Sequence<Any?> { +public fun WithChildren<*>.withDescendants(): Sequence<Any?> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -58,7 +58,7 @@ fun WithChildren<*>.withDescendants(): Sequence<Any?> { } @JvmName("withDescendantsAny") -fun WithChildren<Any>.withDescendants(): Sequence<Any> { +public fun WithChildren<Any>.withDescendants(): Sequence<Any> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -69,13 +69,13 @@ fun WithChildren<Any>.withDescendants(): Sequence<Any> { } } -fun <T> T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren<T> = if (predicate(this)) { +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() } -fun <T : WithChildren<T>> T.asPrintableTree( +public fun <T : WithChildren<T>> T.asPrintableTree( nodeNameBuilder: Appendable.(T) -> Unit = { append(it.toString()) } ): String { fun Appendable.append(element: T, ownPrefix: String, childPrefix: String) { diff --git a/core/src/main/kotlin/model/additionalExtras.kt b/core/src/main/kotlin/model/additionalExtras.kt index 64c1e315..1db8e59d 100644 --- a/core/src/main/kotlin/model/additionalExtras.kt +++ b/core/src/main/kotlin/model/additionalExtras.kt @@ -8,8 +8,11 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -class AdditionalModifiers(val content: SourceSetDependent<Set<ExtraModifiers>>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, AdditionalModifiers> { +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 @@ -19,23 +22,23 @@ class AdditionalModifiers(val content: SourceSetDependent<Set<ExtraModifiers>>) override fun equals(other: Any?): Boolean = if (other is AdditionalModifiers) other.content == content else false - override fun hashCode() = content.hashCode() + override fun hashCode(): Int = content.hashCode() override val key: ExtraProperty.Key<Documentable, *> = AdditionalModifiers } -fun SourceSetDependent<Set<ExtraModifiers>>.toAdditionalModifiers() = AdditionalModifiers(this) +public fun SourceSetDependent<Set<ExtraModifiers>>.toAdditionalModifiers(): AdditionalModifiers = AdditionalModifiers(this) -data class Annotations( +public data class Annotations( private val myContent: SourceSetDependent<List<Annotation>> ) : ExtraProperty<AnnotationTarget> { - companion object : ExtraProperty.Key<AnnotationTarget, Annotations> { + 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 - data class Annotation( + public data class Annotation( val dri: DRI, val params: Map<String, AnnotationParameterValue>, val mustBeDocumented: Boolean = false, @@ -64,51 +67,60 @@ data class Annotations( else Pair(key, withoutFileLevel) }.toMap() - enum class AnnotationScope { + public enum class AnnotationScope { DIRECT, FILE, GETTER, SETTER } } -fun SourceSetDependent<List<Annotations.Annotation>>.toAnnotations() = Annotations(this) +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() -sealed class AnnotationParameterValue -data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() -data class ArrayValue(val value: List<AnnotationParameterValue>) : AnnotationParameterValue() -data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() -data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() -abstract class LiteralValue : AnnotationParameterValue() { - abstract fun text() : String +public abstract class LiteralValue : AnnotationParameterValue() { + public abstract fun text() : String } -data class IntValue(val value: Int) : LiteralValue() { +public data class IntValue(val value: Int) : LiteralValue() { override fun text(): String = value.toString() } -data class LongValue(val value: Long) : LiteralValue() { +public data class LongValue(val value: Long) : LiteralValue() { override fun text(): String = value.toString() } -data class FloatValue(val value: Float) : LiteralValue() { + +public data class FloatValue(val value: Float) : LiteralValue() { override fun text(): String = value.toString() } -data class DoubleValue(val value: Double) : LiteralValue() { + +public data class DoubleValue(val value: Double) : LiteralValue() { override fun text(): String = value.toString() } -object NullValue : LiteralValue() { + +public object NullValue : LiteralValue() { override fun text(): String = "null" } -data class BooleanValue(val value: Boolean) : LiteralValue() { + +public data class BooleanValue(val value: Boolean) : LiteralValue() { override fun text(): String = value.toString() } -data class StringValue(val value: String) : LiteralValue() { + +public data class StringValue(val value: String) : LiteralValue() { override fun text(): String = value override fun toString(): String = value } - -object PrimaryConstructorExtra : ExtraProperty<DFunction>, ExtraProperty.Key<DFunction, PrimaryConstructorExtra> { +public object PrimaryConstructorExtra : ExtraProperty<DFunction>, ExtraProperty.Key<DFunction, PrimaryConstructorExtra> { override val key: ExtraProperty.Key<DFunction, *> = this } -data class ActualTypealias( +public data class ActualTypealias( val typeAlias: DTypeAlias ) : ExtraProperty<DClasslike> { @@ -117,11 +129,11 @@ data class ActualTypealias( val underlyingType: SourceSetDependent<Bound> get() = typeAlias.underlyingType - companion object : ExtraProperty.Key<DClasslike, ActualTypealias> { + public companion object : ExtraProperty.Key<DClasslike, ActualTypealias> { override fun mergeStrategyFor( left: ActualTypealias, right: ActualTypealias - ) = MergeStrategy.Fail { + ): MergeStrategy<DClasslike> = MergeStrategy.Fail { throw IllegalStateException("Adding [ActualTypealias] should be after merging all documentables") } } diff --git a/core/src/main/kotlin/model/ancestryNode.kt b/core/src/main/kotlin/model/ancestryNode.kt index da469eec..7203ab18 100644 --- a/core/src/main/kotlin/model/ancestryNode.kt +++ b/core/src/main/kotlin/model/ancestryNode.kt @@ -4,12 +4,12 @@ package org.jetbrains.dokka.model -data class AncestryNode( +public data class AncestryNode( val typeConstructor: TypeConstructor, val superclass: AncestryNode?, val interfaces: List<AncestryNode>, ) { - fun allImplementedInterfaces(): List<TypeConstructor> { + public fun allImplementedInterfaces(): List<TypeConstructor> { fun traverseInterfaces(ancestry: AncestryNode): List<TypeConstructor> = ancestry.interfaces.flatMap { listOf(it.typeConstructor) + traverseInterfaces(it) } + (ancestry.superclass?.let(::traverseInterfaces) ?: emptyList()) diff --git a/core/src/main/kotlin/model/classKinds.kt b/core/src/main/kotlin/model/classKinds.kt index 7c9461cc..25256022 100644 --- a/core/src/main/kotlin/model/classKinds.kt +++ b/core/src/main/kotlin/model/classKinds.kt @@ -4,9 +4,9 @@ package org.jetbrains.dokka.model -interface ClassKind +public interface ClassKind -enum class KotlinClassKindTypes : ClassKind { +public enum class KotlinClassKindTypes : ClassKind { CLASS, INTERFACE, ENUM_CLASS, @@ -15,7 +15,7 @@ enum class KotlinClassKindTypes : ClassKind { OBJECT; } -enum class JavaClassKindTypes : ClassKind { +public enum class JavaClassKindTypes : ClassKind { CLASS, INTERFACE, ENUM_CLASS, diff --git a/core/src/main/kotlin/model/defaultValues.kt b/core/src/main/kotlin/model/defaultValues.kt index 6d4b2ac0..426954fb 100644 --- a/core/src/main/kotlin/model/defaultValues.kt +++ b/core/src/main/kotlin/model/defaultValues.kt @@ -7,12 +7,15 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -class DefaultValue(val expression: SourceSetDependent<Expression>): ExtraProperty<Documentable> { +public class DefaultValue( + public val expression: SourceSetDependent<Expression> +): ExtraProperty<Documentable> { @Deprecated("Use `expression` property that depends on source set", ReplaceWith("this.expression.values.first()")) - val value: Expression + public val value: Expression get() = expression.values.first() - companion object : ExtraProperty.Key<Documentable, DefaultValue> { + + public companion object : ExtraProperty.Key<Documentable, DefaultValue> { override fun mergeStrategyFor(left: DefaultValue, right: DefaultValue): MergeStrategy<Documentable> = MergeStrategy.Replace(DefaultValue(left.expression + right.expression)) @@ -22,10 +25,10 @@ class DefaultValue(val expression: SourceSetDependent<Expression>): ExtraPropert get() = Companion } -interface Expression -data class ComplexExpression(val value: String) : Expression -data class IntegerConstant(val value: Long) : Expression -data class StringConstant(val value: String) : Expression -data class DoubleConstant(val value: Double) : Expression -data class FloatConstant(val value: Float) : Expression -data class BooleanConstant(val value: Boolean) : Expression +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 index ead64774..f4cb9b33 100644 --- a/core/src/main/kotlin/model/doc/DocTag.kt +++ b/core/src/main/kotlin/model/doc/DocTag.kt @@ -7,363 +7,366 @@ package org.jetbrains.dokka.model.doc import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.WithChildren -sealed class DocTag : WithChildren<DocTag> { - abstract val params: Map<String, String> +public sealed class DocTag : WithChildren<DocTag> { + public abstract val params: Map<String, String> - companion object { - fun contentTypeParam(type: String): Map<String, String> = mapOf("content-type" to type) + public companion object { + public fun contentTypeParam(type: String): Map<String, String> = mapOf("content-type" to type) } } -data class A( +public data class A( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Big( +public data class Big( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class B( +public data class B( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class BlockQuote( +public data class BlockQuote( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -object Br : DocTag() { - override val params = emptyMap<String, String>() - override val children = emptyList<DocTag>() +public object Br : DocTag() { + override val children: List<DocTag> = emptyList() + override val params: Map<String, String> = emptyMap() } -data class Cite( +public data class Cite( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -sealed class Code : DocTag() +public sealed class Code : DocTag() -data class CodeInline( +public data class CodeInline( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : Code() -data class CodeBlock( +public data class CodeBlock( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : Code() -data class CustomDocTag( +public data class CustomDocTag( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap(), val name: String ) : DocTag() -data class Dd( +public data class Dd( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dfn( +public data class Dfn( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dir( +public data class Dir( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Div( +public data class Div( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dl( +public data class Dl( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class DocumentationLink( +public data class DocumentationLink( val dri: DRI, override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dt( +public data class Dt( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Em( +public data class Em( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Font( +public data class Font( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Footer( +public data class Footer( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Frame( +public data class Frame( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class FrameSet( +public data class FrameSet( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H1( +public data class H1( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H2( +public data class H2( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H3( +public data class H3( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H4( +public data class H4( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H5( +public data class H5( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H6( +public data class H6( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Head( +public data class Head( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Header( +public data class Header( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -object HorizontalRule : DocTag() { - override val params = emptyMap<String, String>() - override val children = emptyList<DocTag>() +public object HorizontalRule : DocTag() { + override val children: List<DocTag> = emptyList() + override val params: Map<String, String> = emptyMap() } -data class Html( +public data class Html( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class I( +public data class I( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class IFrame( +public data class IFrame( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Img( +public data class Img( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Index( +public data class Index( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Input( +public data class Input( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Li( +public data class Li( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Link( +public data class Link( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Listing( +public data class Listing( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Main( +public data class Main( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Menu( +public data class Menu( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Meta( +public data class Meta( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Nav( +public data class Nav( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class NoFrames( +public data class NoFrames( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class NoScript( +public data class NoScript( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Ol( +public data class Ol( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class P( +public data class P( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Pre( +public data class Pre( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Script( +public data class Script( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Section( +public data class Section( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Small( +public data class Small( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Span( +public data class Span( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Strikethrough( +public data class Strikethrough( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Strong( +public data class Strong( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Sub( +public data class Sub( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Sup( +public data class Sup( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Table( +public data class Table( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Text( +public data class Text( val body: String = "", override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class TBody( +public data class TBody( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Td( +public data class Td( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class TFoot( +public data class TFoot( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Th( +public data class Th( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class THead( +public data class THead( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Title( +public data class Title( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Tr( +public data class Tr( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Tt( +public data class Tt( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class U(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() -data class Ul( +public data class Ul( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Var( +public data class Var( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Caption( +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 index 1066d941..9c270f79 100644 --- a/core/src/main/kotlin/model/doc/DocumentationNode.kt +++ b/core/src/main/kotlin/model/doc/DocumentationNode.kt @@ -6,4 +6,4 @@ package org.jetbrains.dokka.model.doc import org.jetbrains.dokka.model.WithChildren -data class DocumentationNode(override val children: List<TagWrapper>): WithChildren<TagWrapper> +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 index 45a0b61a..e3eaffb7 100644 --- a/core/src/main/kotlin/model/doc/TagWrapper.kt +++ b/core/src/main/kotlin/model/doc/TagWrapper.kt @@ -7,29 +7,30 @@ package org.jetbrains.dokka.model.doc import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.WithChildren -sealed class TagWrapper : WithChildren<DocTag> { - abstract val root: DocTag +public sealed class TagWrapper : WithChildren<DocTag> { + public abstract val root: DocTag + override val children: List<DocTag> get() = root.children } -sealed class NamedTagWrapper : TagWrapper() { - abstract val name: String +public sealed class NamedTagWrapper : TagWrapper() { + public abstract val name: String } -data class Description(override val root: DocTag) : TagWrapper() -data class Author(override val root: DocTag) : TagWrapper() -data class Version(override val root: DocTag) : TagWrapper() -data class Since(override val root: DocTag) : TagWrapper() -data class See(override val root: DocTag, override val name: String, val address: DRI?) : NamedTagWrapper() -data class Param(override val root: DocTag, override val name: String) : NamedTagWrapper() -data class Return(override val root: DocTag) : TagWrapper() -data class Receiver(override val root: DocTag) : TagWrapper() -data class Constructor(override val root: DocTag) : TagWrapper() +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 -data class Throws(override val root: DocTag, override val name: String, val exceptionAddress: DRI?) : NamedTagWrapper() -data class Sample(override val root: DocTag, override val name: String) : NamedTagWrapper() -data class Deprecated(override val root: DocTag) : TagWrapper() -data class Property(override val root: DocTag, override val name: String) : NamedTagWrapper() -data class Suppress(override val root: DocTag) : TagWrapper() -data class CustomTagWrapper(override val root: DocTag, override val name: String) : NamedTagWrapper() +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 index dc6456f8..b0ebb6ef 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -9,37 +9,37 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -data class InheritedMember(val inheritedFrom: SourceSetDependent<DRI?>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, InheritedMember> { - override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember) = MergeStrategy.Replace( +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) ) } - fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null + public fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null override val key: ExtraProperty.Key<Documentable, *> = InheritedMember } -data class ImplementedInterfaces(val interfaces: SourceSetDependent<List<TypeConstructor>>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, ImplementedInterfaces> { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = +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 } -data class ExceptionInSupertypes(val exceptions: SourceSetDependent<List<TypeConstructor>>): ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, ExceptionInSupertypes> { - override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes) = +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 } -object ObviousMember : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { +public object ObviousMember : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { override val key: ExtraProperty.Key<Documentable, *> = this } @@ -49,12 +49,12 @@ object ObviousMember : ExtraProperty<Documentable>, ExtraProperty.Key<Documentab * 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 */ -object IsVar : ExtraProperty<DProperty>, ExtraProperty.Key<DProperty, IsVar> { +public object IsVar : ExtraProperty<DProperty>, ExtraProperty.Key<DProperty, IsVar> { override val key: ExtraProperty.Key<DProperty, *> = this } -data class IsAlsoParameter(val inSourceSets: List<DokkaSourceSet>) : ExtraProperty<DProperty> { - companion object : ExtraProperty.Key<DProperty, IsAlsoParameter> { +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)) } @@ -62,9 +62,9 @@ data class IsAlsoParameter(val inSourceSets: List<DokkaSourceSet>) : ExtraProper override val key: ExtraProperty.Key<DProperty, *> = IsAlsoParameter } -data class CheckedExceptions(val exceptions: SourceSetDependent<List<DRI>>) : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { - companion object : ExtraProperty.Key<Documentable, CheckedExceptions> { - override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions) = +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 index 5f08a2ce..c9d75bf4 100644 --- a/core/src/main/kotlin/model/documentableUtils.kt +++ b/core/src/main/kotlin/model/documentableUtils.kt @@ -6,10 +6,10 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -fun <T> SourceSetDependent<T>.filtered(sourceSets: Set<DokkaSourceSet>) = filter { it.key in sourceSets } -fun DokkaSourceSet?.filtered(sourceSets: Set<DokkaSourceSet>) = takeIf { this in sourceSets } +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 } -fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>) = +public fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>): DTypeParameter? = if (filteredSet.containsAll(sourceSets)) this else { val intersection = filteredSet.intersect(sourceSets) @@ -24,4 +24,4 @@ fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>) = ) } -fun Documentable.isExtension() = this is Callable && receiver != null +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 index 4eb2a01b..f1193070 100644 --- a/core/src/main/kotlin/model/extraModifiers.kt +++ b/core/src/main/kotlin/model/extraModifiers.kt @@ -4,40 +4,40 @@ package org.jetbrains.dokka.model -sealed class ExtraModifiers(val name: String) { +public sealed class ExtraModifiers(public val name: String) { - sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) { - object Inline : KotlinOnlyModifiers("inline") - object Value : KotlinOnlyModifiers("value") - object Infix : KotlinOnlyModifiers("infix") - object External : KotlinOnlyModifiers("external") - object Suspend : KotlinOnlyModifiers("suspend") - object Reified : KotlinOnlyModifiers("reified") - object CrossInline : KotlinOnlyModifiers("crossinline") - object NoInline : KotlinOnlyModifiers("noinline") - object Override : KotlinOnlyModifiers("override") - object Data : KotlinOnlyModifiers("data") - object Const : KotlinOnlyModifiers("const") - object Inner : KotlinOnlyModifiers("inner") - object LateInit : KotlinOnlyModifiers("lateinit") - object Operator : KotlinOnlyModifiers("operator") - object TailRec : KotlinOnlyModifiers("tailrec") - object VarArg : KotlinOnlyModifiers("vararg") - object Fun : KotlinOnlyModifiers("fun") + 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") } - sealed class JavaOnlyModifiers(name: String) : ExtraModifiers(name) { - object Static : JavaOnlyModifiers("static") - object Native : JavaOnlyModifiers("native") - object Synchronized : JavaOnlyModifiers("synchronized") - object StrictFP : JavaOnlyModifiers("strictfp") - object Transient : JavaOnlyModifiers("transient") - object Volatile : JavaOnlyModifiers("volatile") - object Transitive : JavaOnlyModifiers("transitive") + 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") } - companion object { - fun valueOf(str: String) = when (str) { + public companion object { + public fun valueOf(str: String): ExtraModifiers = when (str) { "inline" -> KotlinOnlyModifiers.Inline "value" -> KotlinOnlyModifiers.Value "infix" -> KotlinOnlyModifiers.Infix diff --git a/core/src/main/kotlin/model/jvmName.kt b/core/src/main/kotlin/model/jvmName.kt index 67df9148..8fd7ccd9 100644 --- a/core/src/main/kotlin/model/jvmName.kt +++ b/core/src/main/kotlin/model/jvmName.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.links.DRI -fun DRI.isJvmName(): Boolean = packageName == "kotlin.jvm" && classNames == "JvmName" +public fun DRI.isJvmName(): Boolean = packageName == "kotlin.jvm" && classNames == "JvmName" -fun Annotations.Annotation.isJvmName(): Boolean = dri.isJvmName() +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 index 24577bd5..7f5bb2f0 100644 --- a/core/src/main/kotlin/model/properties/PropertyContainer.kt +++ b/core/src/main/kotlin/model/properties/PropertyContainer.kt @@ -4,43 +4,44 @@ package org.jetbrains.dokka.model.properties -data class PropertyContainer<C : Any> internal constructor( +public data class PropertyContainer<C : Any> internal constructor( @PublishedApi internal val map: Map<ExtraProperty.Key<C, *>, ExtraProperty<C>> ) { - operator fun <D : C> plus(prop: ExtraProperty<D>): PropertyContainer<D> = + public operator fun <D : C> plus(prop: ExtraProperty<D>): PropertyContainer<D> = PropertyContainer(map + (prop.key to prop)) // TODO: Add logic for caching calculated properties - inline operator fun <reified T : Any> get(key: ExtraProperty.Key<C, T>): T? = when (val prop = map[key]) { + 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.") } - inline fun <reified T : Any> allOfType(): List<T> = map.values.filterIsInstance<T>() - fun <D : C> addAll(extras: Collection<ExtraProperty<D>>): PropertyContainer<D> = + 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 }) - operator fun <D : C> minus(prop: ExtraProperty.Key<C, *>): PropertyContainer<D> = + public operator fun <D : C> minus(prop: ExtraProperty.Key<C, *>): PropertyContainer<D> = PropertyContainer(map.filterNot { it.key == prop }) - companion object { - fun <T : Any> empty(): PropertyContainer<T> = PropertyContainer(emptyMap()) - fun <T : Any> withAll(vararg extras: ExtraProperty<T>?) = empty<T>().addAll(extras.filterNotNull()) - fun <T : Any> withAll(extras: Collection<ExtraProperty<T>>) = empty<T>().addAll(extras) + 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) } } -operator fun <D: Any> PropertyContainer<D>.plus(prop: ExtraProperty<D>?): PropertyContainer<D> = +public operator fun <D: Any> PropertyContainer<D>.plus(prop: ExtraProperty<D>?): PropertyContainer<D> = if (prop == null) this else PropertyContainer(map + (prop.key to prop)) -interface WithExtraProperties<C : Any> { - val extra: PropertyContainer<C> +public interface WithExtraProperties<C : Any> { + public val extra: PropertyContainer<C> - fun withNewExtras(newExtras: PropertyContainer<C>): C + public fun withNewExtras(newExtras: PropertyContainer<C>): C } -fun <C> C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties<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 } diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt index e15a1668..ea76dc72 100644 --- a/core/src/main/kotlin/model/properties/properties.kt +++ b/core/src/main/kotlin/model/properties/properties.kt @@ -4,23 +4,33 @@ package org.jetbrains.dokka.model.properties -interface ExtraProperty<in C : Any> { - interface Key<in C : Any, T : Any> { - fun mergeStrategyFor(left: T, right: T): MergeStrategy<C> = MergeStrategy.Fail { +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") } } - val key: Key<C, *> + public val key: Key<C, *> } -interface CalculatedProperty<in C : Any, T : Any> : ExtraProperty.Key<C, T> { - fun calculate(subject: C): T +public interface CalculatedProperty<in C : Any, T : Any> : ExtraProperty.Key<C, T> { + public fun calculate(subject: C): T } -sealed class MergeStrategy<in C> { - class Replace<in C : Any>(val newProperty: ExtraProperty<C>) : MergeStrategy<C>() - object Remove : MergeStrategy<Any>() - class Full<C : Any>(val merger: (preMerged: C, left: C, right: C) -> C) : MergeStrategy<C>() - class Fail(val error: () -> Nothing) : MergeStrategy<Any>() +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>() } |