Use describe instead of tables for supported operations.

This commit is contained in:
Rapptz 2017-05-13 18:48:14 -04:00
parent 96eca8aa53
commit f73eb087c9
9 changed files with 206 additions and 168 deletions

View File

@ -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
----------

View File

@ -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
-----------

View File

@ -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
-----------

View File

@ -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
----------

View File

@ -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
-----------

View File

@ -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
----------

View File

@ -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
-----------

View File

@ -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
----------

View File

@ -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
-----------