Skip to content

Commit

Permalink
Add documentation for values and code/value
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann committed Aug 20, 2023
1 parent 83cc3d8 commit 02eebc3
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = ActivityFlags.Serializer::class)
public class ActivityFlags internal constructor(
/**
* The raw value used by Discord.
*/
public val `value`: Int,
) {
/**
* A [Set] of all [ActivityFlag]s contained in this instance of [ActivityFlags].
*/
public val values: Set<ActivityFlag>
get() = buildSet {
var remaining = value
Expand All @@ -92,6 +98,9 @@ public class ActivityFlags internal constructor(
}
}

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'values'.",
replaceWith = ReplaceWith(expression = "this.values", imports = arrayOf()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = ApplicationFlags.Serializer::class)
public class ApplicationFlags internal constructor(
/**
* The raw code used by Discord.
*/
public val code: Int,
) {
/**
* A [Set] of all [ApplicationFlag]s contained in this instance of [ApplicationFlags].
*/
public val values: Set<ApplicationFlag>
get() = buildSet {
var remaining = code
Expand All @@ -96,6 +102,9 @@ public class ApplicationFlags internal constructor(
}
}

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'values'.",
replaceWith = ReplaceWith(expression = "this.values", imports = arrayOf()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = ChannelFlags.Serializer::class)
public class ChannelFlags internal constructor(
/**
* The raw code used by Discord.
*/
public val code: Int,
) {
/**
* A [Set] of all [ChannelFlag]s contained in this instance of [ChannelFlags].
*/
public val values: Set<ChannelFlag>
get() = buildSet {
var remaining = code
Expand All @@ -92,6 +98,9 @@ public class ChannelFlags internal constructor(
}
}

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'values'.",
replaceWith = ReplaceWith(expression = "this.values", imports = arrayOf()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = GuildMemberFlags.Serializer::class)
public class GuildMemberFlags internal constructor(
/**
* The raw code used by Discord.
*/
public val code: Int,
) {
/**
* A [Set] of all [GuildMemberFlag]s contained in this instance of [GuildMemberFlags].
*/
public val values: Set<GuildMemberFlag>
get() = buildSet {
var remaining = code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = MessageFlags.Serializer::class)
public class MessageFlags internal constructor(
/**
* The raw code used by Discord.
*/
public val code: Int,
) {
/**
* A [Set] of all [MessageFlag]s contained in this instance of [MessageFlags].
*/
public val values: Set<MessageFlag>
get() = buildSet {
var remaining = code
Expand All @@ -92,6 +98,9 @@ public class MessageFlags internal constructor(
}
}

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'values'.",
replaceWith = ReplaceWith(expression = "this.values", imports = arrayOf()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = Permissions.Serializer::class)
public class Permissions internal constructor(
/**
* The raw code used by Discord.
*/
public val code: DiscordBitSet,
) {
/**
* A [Set] of all [Permission]s contained in this instance of [Permissions].
*/
public val values: Set<Permission>
get() = buildSet {
for (shift in 0..<code.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = SystemChannelFlags.Serializer::class)
public class SystemChannelFlags internal constructor(
/**
* The raw code used by Discord.
*/
public val code: Int,
) {
/**
* A [Set] of all [SystemChannelFlag]s contained in this instance of [SystemChannelFlags].
*/
public val values: Set<SystemChannelFlag>
get() = buildSet {
var remaining = code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = UserFlags.Serializer::class)
public class UserFlags internal constructor(
/**
* The raw code used by Discord.
*/
public val code: Int,
) {
/**
* A [Set] of all [UserFlag]s contained in this instance of [UserFlags].
*/
public val values: Set<UserFlag>
get() = buildSet {
var remaining = code
Expand All @@ -92,6 +98,9 @@ public class UserFlags internal constructor(
}
}

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'values'.",
replaceWith = ReplaceWith(expression = "this.values", imports = arrayOf()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = Intents.Serializer::class)
public class Intents internal constructor(
/**
* The raw code used by Discord.
*/
public val code: DiscordBitSet,
) {
/**
* A [Set] of all [Intent]s contained in this instance of [Intents].
*/
public val values: Set<Intent>
get() = buildSet {
for (shift in 0..<code.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ internal fun BitFlags.generateFileSpec(originatingFile: KSFile) = fileSpecForGen
addParameter(valueName, valueCN)
}
addProperty(valueName, valueCN, PUBLIC) {
addKdoc("The raw $valueName used by Discord.")
initializer(valueName)
}
addProperty("values", type = SET.parameterizedBy(entityCN), PUBLIC) {
addKdoc("A [Set] of all [%T]s contained in this instance of [%T].", entityCN, collectionCN)
getter {
withControlFlow("return buildSet") {
when (valueType) {
Expand All @@ -57,6 +59,7 @@ internal fun BitFlags.generateFileSpec(originatingFile: KSFile) = fileSpecForGen
if (hadFlagsProperty) {
val type = (if (flagsPropertyWasSet) SET else LIST).parameterizedBy(entityCN)
addProperty("flags", type, PUBLIC) {
addKdoc("@suppress")
@OptIn(DelicateKotlinPoetApi::class)
addAnnotation(
Deprecated(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ import kotlinx.serialization.encoding.Encoder
*/
@Serializable(with = SpeakingFlags.Serializer::class)
public class SpeakingFlags internal constructor(
/**
* The raw code used by Discord.
*/
public val code: Int,
) {
/**
* A [Set] of all [SpeakingFlag]s contained in this instance of [SpeakingFlags].
*/
public val values: Set<SpeakingFlag>
get() = buildSet {
var remaining = code
Expand All @@ -92,6 +98,9 @@ public class SpeakingFlags internal constructor(
}
}

/**
* @suppress
*/
@Deprecated(
message = "Renamed to 'values'.",
replaceWith = ReplaceWith(expression = "this.values", imports = arrayOf()),
Expand Down

0 comments on commit 02eebc3

Please sign in to comment.