From f73eb087c99a0ee73b9a46500225464ab866c625 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 13 May 2017 18:48:14 -0400 Subject: [PATCH] Use describe instead of tables for supported operations. --- discord/channel.py | 104 ++++++++++++++++++++++++-------------------- discord/emoji.py | 36 +++++++-------- discord/game.py | 26 ++++++----- discord/guild.py | 26 ++++++----- discord/invite.py | 26 ++++++----- discord/member.py | 28 +++++++----- discord/reaction.py | 26 ++++++----- discord/role.py | 50 ++++++++++++--------- discord/user.py | 52 ++++++++++++---------- 9 files changed, 206 insertions(+), 168 deletions(-) diff --git a/discord/channel.py b/discord/channel.py index 4391b8476..bf0175452 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -44,19 +44,21 @@ def _single_delete_strategy(messages, *, reason): class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): """Represents a Discord guild text channel. - Supported Operations: + .. describe:: x == y - +-----------+---------------------------------------+ - | Operation | Description | - +===========+=======================================+ - | x == y | Checks if two channels are equal. | - +-----------+---------------------------------------+ - | x != y | Checks if two channels are not equal. | - +-----------+---------------------------------------+ - | hash(x) | Returns the channel's hash. | - +-----------+---------------------------------------+ - | str(x) | Returns the channel's name. | - +-----------+---------------------------------------+ + Checks if two channels are equal. + + .. describe:: x != y + + Checks if two channels are not equal. + + .. describe:: hash(x) + + Returns the channel's hash. + + .. describe:: str(x) + + Returns the channel's name. Attributes ----------- @@ -300,19 +302,21 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable): """Represents a Discord guild voice channel. - Supported Operations: + .. describe:: x == y - +-----------+---------------------------------------+ - | Operation | Description | - +===========+=======================================+ - | x == y | Checks if two channels are equal. | - +-----------+---------------------------------------+ - | x != y | Checks if two channels are not equal. | - +-----------+---------------------------------------+ - | hash(x) | Returns the channel's hash. | - +-----------+---------------------------------------+ - | str(x) | Returns the channel's name. | - +-----------+---------------------------------------+ + Checks if two channels are equal. + + .. describe:: x != y + + Checks if two channels are not equal. + + .. describe:: hash(x) + + Returns the channel's hash. + + .. describe:: str(x) + + Returns the channel's name. Attributes ----------- @@ -410,19 +414,21 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable): class DMChannel(discord.abc.Messageable, Hashable): """Represents a Discord direct message channel. - Supported Operations: + .. describe:: x == y - +-----------+-------------------------------------------------+ - | Operation | Description | - +===========+=================================================+ - | x == y | Checks if two channels are equal. | - +-----------+-------------------------------------------------+ - | x != y | Checks if two channels are not equal. | - +-----------+-------------------------------------------------+ - | hash(x) | Returns the channel's hash. | - +-----------+-------------------------------------------------+ - | str(x) | Returns a string representation of the channel | - +-----------+-------------------------------------------------+ + Checks if two channels are equal. + + .. describe:: x != y + + Checks if two channels are not equal. + + .. describe:: hash(x) + + Returns the channel's hash. + + .. describe:: str(x) + + Returns a string representation of the channel Attributes ---------- @@ -489,19 +495,21 @@ class DMChannel(discord.abc.Messageable, Hashable): class GroupChannel(discord.abc.Messageable, Hashable): """Represents a Discord group channel. - Supported Operations: + .. describe:: x == y - +-----------+-------------------------------------------------+ - | Operation | Description | - +===========+=================================================+ - | x == y | Checks if two channels are equal. | - +-----------+-------------------------------------------------+ - | x != y | Checks if two channels are not equal. | - +-----------+-------------------------------------------------+ - | hash(x) | Returns the channel's hash. | - +-----------+-------------------------------------------------+ - | str(x) | Returns a string representation of the channel | - +-----------+-------------------------------------------------+ + Checks if two channels are equal. + + .. describe:: x != y + + Checks if two channels are not equal. + + .. describe:: hash(x) + + Returns the channel's hash. + + .. describe:: str(x) + + Returns a string representation of the channel Attributes ---------- diff --git a/discord/emoji.py b/discord/emoji.py index 3c61b1371..02df71d6b 100644 --- a/discord/emoji.py +++ b/discord/emoji.py @@ -38,24 +38,26 @@ class Emoji(Hashable): Depending on the way this object was created, some of the attributes can have a value of ``None``. - Supported Operations: + .. describe:: x == y - +-----------+-----------------------------------------+ - | Operation | Description | - +===========+=========================================+ - | x == y | Checks if two emoji are the same. | - +-----------+-----------------------------------------+ - | x != y | Checks if two emoji are not the same. | - +-----------+-----------------------------------------+ - | hash(x) | Return the emoji's hash. | - +-----------+-----------------------------------------+ - | iter(x) | Returns an iterator of (field, value) | - | | pairs. This allows this class to be | - | | used as an iterable in list/dict/etc. | - | | constructions. | - +-----------+-----------------------------------------+ - | str(x) | Returns the emoji rendered for discord. | - +-----------+-----------------------------------------+ + Checks if two emoji are the same. + + .. describe:: x != y + + Checks if two emoji are not the same. + + .. describe:: hash(x) + + Return the emoji's hash. + + .. describe:: iter(x) + + Returns an iterator of ``(field, value)`` pairs. This allows this class + to be used as an iterable in list/dict/etc constructions. + + .. describe:: str(x) + + Returns the emoji rendered for discord. Attributes ----------- diff --git a/discord/game.py b/discord/game.py index 2cb3587ad..6e8ed5cf4 100644 --- a/discord/game.py +++ b/discord/game.py @@ -27,19 +27,21 @@ DEALINGS IN THE SOFTWARE. class Game: """Represents a Discord game. - Supported Operations: + .. describe:: x == y - +-----------+------------------------------------+ - | Operation | Description | - +===========+====================================+ - | x == y | Checks if two games are equal. | - +-----------+------------------------------------+ - | x != y | Checks if two games are not equal. | - +-----------+------------------------------------+ - | hash(x) | Return the games's hash. | - +-----------+------------------------------------+ - | str(x) | Returns the games's name. | - +-----------+------------------------------------+ + Checks if two games are equal. + + .. describe:: x != y + + Checks if two games are not equal. + + .. describe:: hash(x) + + Returns the game's hash. + + .. describe:: str(x) + + Returns the game's name. Attributes ----------- diff --git a/discord/guild.py b/discord/guild.py index 4987ea369..b0b9b02db 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -50,19 +50,21 @@ class Guild(Hashable): This is referred to as a "server" in the official Discord UI. - Supported Operations: + .. describe:: x == y - +-----------+-------------------------------------+ - | Operation | Description | - +===========+=====================================+ - | x == y | Checks if two guilds are equal. | - +-----------+-------------------------------------+ - | x != y | Checks if two guilds are not equal. | - +-----------+-------------------------------------+ - | hash(x) | Returns the guild's hash. | - +-----------+-------------------------------------+ - | str(x) | Returns the guild's name. | - +-----------+-------------------------------------+ + Checks if two guilds are equal. + + .. describe:: x != y + + Checks if two guilds are not equal. + + .. describe:: hash(x) + + Returns the guild's hash. + + .. describe:: str(x) + + Returns the guild's name. Attributes ---------- diff --git a/discord/invite.py b/discord/invite.py index 44aa90f6b..2139500c5 100644 --- a/discord/invite.py +++ b/discord/invite.py @@ -36,19 +36,21 @@ class Invite(Hashable): Depending on the way this object was created, some of the attributes can have a value of ``None``. - Supported Operations: + .. describe:: x == y - +-----------+--------------------------------------+ - | Operation | Description | - +===========+======================================+ - | x == y | Checks if two invites are equal. | - +-----------+--------------------------------------+ - | x != y | Checks if two invites are not equal. | - +-----------+--------------------------------------+ - | hash(x) | Return the invite's hash. | - +-----------+--------------------------------------+ - | str(x) | Returns the invite's URL. | - +-----------+--------------------------------------+ + Checks if two invites are equal. + + .. describe:: x != y + + Checks if two invites are not equal. + + .. describe:: hash(x) + + Returns the invite hash. + + .. describe:: str(x) + + Returns the invite URL. Attributes ----------- diff --git a/discord/member.py b/discord/member.py index c5d0f45c4..7dc08df4c 100644 --- a/discord/member.py +++ b/discord/member.py @@ -112,19 +112,23 @@ class Member(discord.abc.Messageable): This implements a lot of the functionality of :class:`User`. - Supported Operations: + .. describe:: x == y - +-----------+-----------------------------------------------+ - | Operation | Description | - +===========+===============================================+ - | x == y | Checks if two members are equal. | - +-----------+-----------------------------------------------+ - | x != y | Checks if two members are not equal. | - +-----------+-----------------------------------------------+ - | hash(x) | Return the member's hash. | - +-----------+-----------------------------------------------+ - | str(x) | Returns the member's name with discriminator. | - +-----------+-----------------------------------------------+ + Checks if two members are equal. + Note that this works with :class:`User` instances too. + + .. describe:: x != y + + Checks if two members are not equal. + Note that this works with :class:`User` instances too. + + .. describe:: hash(x) + + Returns the member's hash. + + .. describe:: str(x) + + Returns the member's name with the discriminator. Attributes ---------- diff --git a/discord/reaction.py b/discord/reaction.py index d4a7bcdff..968620747 100644 --- a/discord/reaction.py +++ b/discord/reaction.py @@ -32,19 +32,23 @@ class Reaction: Depending on the way this object was created, some of the attributes can have a value of ``None``. - Similar to members, the same reaction to a different message are equal. + .. describe:: x == y - Supported Operations: + Checks if two reactions are equal. This works by checking if the emoji + is the same. So two messages with the same reaction will be considered + "equal". - +-----------+-------------------------------------------+ - | Operation | Description | - +===========+===========================================+ - | x == y | Checks if two reactions are the same. | - +-----------+-------------------------------------------+ - | x != y | Checks if two reactions are not the same. | - +-----------+-------------------------------------------+ - | hash(x) | Return the emoji's hash. | - +-----------+-------------------------------------------+ + .. describe:: x != y + + Checks if two reactions are not equal. + + .. describe:: hash(x) + + Returns the reaction's hash. + + .. describe:: str(x) + + Returns the channel's name. Attributes ----------- diff --git a/discord/role.py b/discord/role.py index 088a076b1..d19a5bec6 100644 --- a/discord/role.py +++ b/discord/role.py @@ -35,27 +35,37 @@ from .utils import snowflake_time class Role(Hashable): """Represents a Discord role in a :class:`Guild`. - Supported Operations: + .. describe:: x == y - +-----------+------------------------------------------------------------------+ - | Operation | Description | - +===========+==================================================================+ - | x == y | Checks if two roles are equal. | - +-----------+------------------------------------------------------------------+ - | x != y | Checks if two roles are not equal. | - +-----------+------------------------------------------------------------------+ - | x > y | Checks if a role is higher than another in the hierarchy. | - +-----------+------------------------------------------------------------------+ - | x < y | Checks if a role is lower than another in the hierarchy. | - +-----------+------------------------------------------------------------------+ - | x >= y | Checks if a role is higher or equal to another in the hierarchy. | - +-----------+------------------------------------------------------------------+ - | x <= y | Checks if a role is lower or equal to another in the hierarchy. | - +-----------+------------------------------------------------------------------+ - | hash(x) | Return the role's hash. | - +-----------+------------------------------------------------------------------+ - | str(x) | Returns the role's name. | - +-----------+------------------------------------------------------------------+ + Checks if two roles are equal. + + .. describe:: x != y + + Checks if two roles are not equal. + + .. describe:: x > y + + Checks if a role is higher than another in the hierarchy. + + .. describe:: x < y + + Checks if a role is lower than another in the hierarchy. + + .. describe:: x >= y + + Checks if a role is higher or equal to another in the hierarchy. + + .. describe:: x <= y + + Checks if a role is lower or equal to another in the hierarchy. + + .. describe:: hash(x) + + Return the role's hash. + + .. describe:: str(x) + + Returns the role's name. Attributes ---------- diff --git a/discord/user.py b/discord/user.py index 2f3bfade6..e7171b3cc 100644 --- a/discord/user.py +++ b/discord/user.py @@ -175,19 +175,21 @@ class BaseUser: class ClientUser(BaseUser): """Represents your Discord user. - Supported Operations: + .. describe:: x == y - +-----------+---------------------------------------------+ - | Operation | Description | - +===========+=============================================+ - | x == y | Checks if two users are equal. | - +-----------+---------------------------------------------+ - | x != y | Checks if two users are not equal. | - +-----------+---------------------------------------------+ - | hash(x) | Return the user's hash. | - +-----------+---------------------------------------------+ - | str(x) | Returns the user's name with discriminator. | - +-----------+---------------------------------------------+ + Checks if two users are equal. + + .. describe:: x != y + + Checks if two users are not equal. + + .. describe:: hash(x) + + Return the user's hash. + + .. describe:: str(x) + + Returns the user's name with discriminator. Attributes ----------- @@ -382,19 +384,21 @@ class ClientUser(BaseUser): class User(BaseUser, discord.abc.Messageable): """Represents a Discord user. - Supported Operations: + .. describe:: x == y - +-----------+---------------------------------------------+ - | Operation | Description | - +===========+=============================================+ - | x == y | Checks if two users are equal. | - +-----------+---------------------------------------------+ - | x != y | Checks if two users are not equal. | - +-----------+---------------------------------------------+ - | hash(x) | Return the user's hash. | - +-----------+---------------------------------------------+ - | str(x) | Returns the user's name with discriminator. | - +-----------+---------------------------------------------+ + Checks if two users are equal. + + .. describe:: x != y + + Checks if two users are not equal. + + .. describe:: hash(x) + + Return the user's hash. + + .. describe:: str(x) + + Returns the user's name with discriminator. Attributes -----------