Skip to content

Commit

Permalink
Document deprecation cycle of deprecated declarations (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann authored Aug 19, 2024
1 parent e2e5f19 commit a4311db
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public class Permissions internal constructor(

@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun copy0(builder: Builder.() -> Unit): Permissions {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down Expand Up @@ -620,7 +620,8 @@ public class Permissions internal constructor(
@Suppress(names = arrayOf("DEPRECATION_ERROR"))
@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "Permissions.Companion", imports =
arrayOf("dev.kord.common.entity.Permissions")),
)
Expand All @@ -630,7 +631,8 @@ public class Permissions internal constructor(

@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "Permissions.Companion", imports =
arrayOf("dev.kord.common.entity.Permissions")),
)
Expand All @@ -650,7 +652,7 @@ public inline fun Permissions(builder: Permissions.Builder.() -> Unit = {}): Per
@Suppress(names = arrayOf("FunctionName"))
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun Permissions0(builder: Permissions.Builder.() -> Unit = {}): Permissions {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ public class SystemChannelFlags internal constructor(
@Suppress(names = arrayOf("DEPRECATION_ERROR"))
@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "SystemChannelFlags.Companion", imports =
arrayOf("dev.kord.common.entity.SystemChannelFlags")),
)
Expand All @@ -340,7 +341,8 @@ public class SystemChannelFlags internal constructor(

@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "SystemChannelFlags.Companion", imports =
arrayOf("dev.kord.common.entity.SystemChannelFlags")),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public class UserFlags internal constructor(

@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun copy0(builder: Builder.() -> Unit): UserFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/DiscordBitSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public fun DiscordBitSet(value: String): DiscordBitSet {


@Deprecated(
"Replaced by 'DiscordBitSet.serializer()'.",
"Replaced by 'DiscordBitSet.serializer()'. This declaration will be removed in 0.16.0.",
ReplaceWith("DiscordBitSet.serializer()", imports = ["dev.kord.common.DiscordBitSet"]),
DeprecationLevel.HIDDEN,
)
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/Locale.kt
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public data class Locale(val language: String, val country: String? = null) {
}

@Deprecated(
"Replaced by 'Locale.serializer()'.",
"Replaced by 'Locale.serializer()'. This declaration will be removed in 0.16.0.",
ReplaceWith("Locale.serializer()", imports = ["dev.kord.common.Locale"]),
DeprecationLevel.HIDDEN,
)
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/entity/DiscordChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public sealed class ArchiveDuration(
@Suppress("UNUSED_PARAMETER") unused: Nothing?,
) : ArchiveDuration(duration) {
@Deprecated(
"Replaced by 'ArchiveDuration.from()'.",
"Replaced by 'ArchiveDuration.from()'. This declaration will be removed in 0.16.0.",
ReplaceWith("ArchiveDuration.from(duration)", imports = ["dev.kord.common.entity.ArchiveDuration"]),
DeprecationLevel.HIDDEN,
)
Expand Down
6 changes: 4 additions & 2 deletions common/src/commonMain/kotlin/entity/DiscordShard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public data class DiscordShard(val index: Int, val count: Int) {
public companion object {
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"Renamed to 'Companion'.",
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration " +
"will be removed in 0.17.0.",
ReplaceWith("DiscordShard.Companion", imports = ["dev.kord.common.entity.DiscordShard"]),
DeprecationLevel.ERROR,
)
Expand All @@ -44,7 +45,8 @@ public data class DiscordShard(val index: Int, val count: Int) {
}

@Deprecated(
"Renamed to 'Companion'.",
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will " +
"be removed in 0.17.0.",
ReplaceWith("DiscordShard.Companion", imports = ["dev.kord.common.entity.DiscordShard"]),
DeprecationLevel.ERROR,
)
Expand Down
3 changes: 2 additions & 1 deletion common/src/commonMain/kotlin/entity/Permissions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public val Permissions.Companion.ALL: Permissions get() = ALL_PERMISSIONS

@Suppress("UnusedReceiverParameter", "DEPRECATION_ERROR")
@Deprecated(
"'Permissions.NewCompanion' was renamed to 'Permissions.Companion'. Use 'Permissions.Companion.ALL' instead.",
"'Permissions.NewCompanion' was renamed to 'Permissions.Companion'. Use 'Permissions.Companion.ALL' instead. The " +
"deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
ReplaceWith("Permissions.ALL", imports = ["dev.kord.common.entity.Permissions", "dev.kord.common.entity.ALL"]),
DeprecationLevel.ERROR,
)
Expand Down
2 changes: 1 addition & 1 deletion core/src/commonMain/kotlin/Kord.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import kotlin.contracts.contract
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.channels.Channel as CoroutineChannel

@Deprecated("Use your own logger instead, this will be removed in the future.", level = DeprecationLevel.HIDDEN)
@Deprecated("Use your own logger instead. This declaration will be removed in 0.16.0.", level = DeprecationLevel.HIDDEN)
public val kordLogger: mu.KLogger = mu.KotlinLogging.logger { }

private val logger = KotlinLogging.logger { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import dev.kord.core.event.Event

@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public sealed interface ApplicationCommandCreateEvent : Event {
Expand All @@ -17,7 +18,8 @@ public sealed interface ApplicationCommandCreateEvent : Event {
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class ChatInputCommandCreateEvent(
Expand All @@ -31,7 +33,8 @@ public class ChatInputCommandCreateEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class UserCommandCreateEvent(
Expand All @@ -45,7 +48,8 @@ public class UserCommandCreateEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class MessageCommandCreateEvent(
Expand All @@ -59,7 +63,8 @@ public class MessageCommandCreateEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class UnknownApplicationCommandCreateEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import dev.kord.core.event.Event

@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public sealed interface ApplicationCommandDeleteEvent : Event {
Expand All @@ -17,7 +18,8 @@ public sealed interface ApplicationCommandDeleteEvent : Event {
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class ChatInputCommandDeleteEvent(
Expand All @@ -31,7 +33,8 @@ public class ChatInputCommandDeleteEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class UserCommandDeleteEvent(
Expand All @@ -45,7 +48,8 @@ public class UserCommandDeleteEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class MessageCommandDeleteEvent(
Expand All @@ -59,7 +63,8 @@ public class MessageCommandDeleteEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class UnknownApplicationCommandDeleteEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import dev.kord.core.event.Event

@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public sealed interface ApplicationCommandUpdateEvent : Event {
Expand All @@ -17,7 +18,8 @@ public sealed interface ApplicationCommandUpdateEvent : Event {
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class ChatInputCommandUpdateEvent(
Expand All @@ -31,7 +33,8 @@ public class ChatInputCommandUpdateEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class UserCommandUpdateEvent(
Expand All @@ -45,7 +48,8 @@ public class UserCommandUpdateEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class MessageCommandUpdateEvent(
Expand All @@ -58,7 +62,8 @@ public class MessageCommandUpdateEvent(
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public class UnknownApplicationCommandUpdateEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public class Intents internal constructor(

@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun copy0(builder: Builder.() -> Unit): Intents {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down Expand Up @@ -502,7 +502,7 @@ public inline fun Intents(builder: Intents.Builder.() -> Unit = {}): Intents {
@Suppress(names = arrayOf("FunctionName"))
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun Intents0(builder: Intents.Builder.() -> Unit = {}): Intents {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down
35 changes: 26 additions & 9 deletions gateway/src/commonMain/kotlin/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,35 @@ public data class Heartbeat(val data: Long?) : Event() {
override fun deserialize(decoder: Decoder) = Heartbeat(decoder.decodeSerializableValue(delegate))
}

@Deprecated("Binary compatibility, keep for some releases.", level = DeprecationLevel.HIDDEN)
@Deprecated(
"Kept for binary compatibility, this declaration will be removed in 0.18.0.",
level = DeprecationLevel.HIDDEN,
)
public constructor(data: Long) : this(data as Long?)

@Suppress("PropertyName")
@Deprecated("Binary compatibility, keep for some releases.", level = DeprecationLevel.HIDDEN)
@Deprecated(
"Kept for binary compatibility, this declaration will be removed in 0.18.0.",
level = DeprecationLevel.HIDDEN,
)
@get:JvmName("getData")
public val data_: Long
get() = data ?: throw NullPointerException("This heartbeat request contains a null sequence number")

@Suppress("FunctionName")
@Deprecated("Binary compatibility, keep for some releases.", level = DeprecationLevel.HIDDEN)
@Deprecated(
"Kept for binary compatibility, this declaration will be removed in 0.18.0.",
level = DeprecationLevel.HIDDEN,
)
@JvmName("component1")
public fun component1_(): Long =
component1() ?: throw NullPointerException("This heartbeat request contains a null sequence number")

@Suppress("FunctionName")
@Deprecated("Binary compatibility, keep for some releases.", level = DeprecationLevel.HIDDEN)
@Deprecated(
"Kept for binary compatibility, this declaration will be removed in 0.18.0.",
level = DeprecationLevel.HIDDEN,
)
@JvmName("copy")
public fun copy_(
data: Long = this.data ?: throw NullPointerException("This heartbeat request contains a null sequence number"),
Expand All @@ -327,7 +339,8 @@ public data class Heartbeat(val data: Long?) : Event() {
public companion object {
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"Renamed to 'Companion'.",
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration " +
"will be removed in 0.17.0.",
ReplaceWith("Heartbeat.Companion", imports = ["dev.kord.gateway.Heartbeat"]),
DeprecationLevel.ERROR,
)
Expand All @@ -336,7 +349,8 @@ public data class Heartbeat(val data: Long?) : Event() {
}

@Deprecated(
"Renamed to 'Companion'.",
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will " +
"be removed in 0.17.0.",
ReplaceWith("Heartbeat.Companion", imports = ["dev.kord.gateway.Heartbeat"]),
DeprecationLevel.ERROR,
)
Expand Down Expand Up @@ -535,7 +549,8 @@ public data class InteractionCreate(val interaction: DiscordInteraction, overrid

@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public data class ApplicationCommandCreate(val application: DiscordApplicationCommand, override val sequence: Int?) :
Expand All @@ -544,7 +559,8 @@ public data class ApplicationCommandCreate(val application: DiscordApplicationCo

@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public data class ApplicationCommandUpdate(val application: DiscordApplicationCommand, override val sequence: Int?) :
Expand All @@ -553,7 +569,8 @@ public data class ApplicationCommandUpdate(val application: DiscordApplicationCo

@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
"details. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in " +
"0.17.0.",
level = DeprecationLevel.ERROR,
)
public data class ApplicationCommandDelete(val application: DiscordApplicationCommand, override val sequence: Int?) :
Expand Down
Loading

0 comments on commit a4311db

Please sign in to comment.