aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-03-12 01:07:47 -0400
committerRapptz <[email protected]>2019-03-12 01:15:24 -0400
commit13b23963ec626f549852a71180d9ee193e73e611 (patch)
treebbbc1b2d0916a284319b2efa38259ed3c0d22a5f /docs
parentRevert default parameter use_cached of Attachment.save back to False. (diff)
downloaddiscord.py-13b23963ec626f549852a71180d9ee193e73e611.tar.xz
discord.py-13b23963ec626f549852a71180d9ee193e73e611.zip
Add exception hierarchy to the documentation.
Diffstat (limited to 'docs')
-rw-r--r--docs/_static/style.css15
-rw-r--r--docs/api.rst17
-rw-r--r--docs/conf.py3
-rw-r--r--docs/ext/commands/api.rst26
-rw-r--r--docs/extensions/exception_hierarchy.py27
5 files changed, 85 insertions, 3 deletions
diff --git a/docs/_static/style.css b/docs/_static/style.css
index 6073b370..81166de4 100644
--- a/docs/_static/style.css
+++ b/docs/_static/style.css
@@ -322,6 +322,21 @@ div.helpful > p.admonition-title:after {
content: unset;
}
+/* exception hierarchy */
+
+.exception-hierarchy-content dd,
+.exception-hierarchy-content dl {
+ margin: 0px 2px;
+}
+
+.exception-hierarchy-content {
+ margin-left: 0.5em;
+}
+
+.exception-hierarchy-content ul {
+ list-style: 'ยป' !important;
+}
+
pre {
background-color: #f5f5f5;
border: 1px solid #C6C9CB;
diff --git a/docs/api.rst b/docs/api.rst
index b80ee139..d1d2e754 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -2196,3 +2196,20 @@ The following exceptions are thrown by the library.
.. autoexception:: discord.opus.OpusError
.. autoexception:: discord.opus.OpusNotLoaded
+
+Exception Hierarchy
+~~~~~~~~~~~~~~~~~~~~~
+
+.. exception_hierarchy::
+
+ - :exc:`Exception`
+ - :exc:`DiscordException`
+ - :exc:`ClientException`
+ - :exc:`NoMoreItems`
+ - :exc:`GatewayNotFound`
+ - :exc:`HTTPException`
+ - :exc:`Forbidden`
+ - :exc:`NotFound`
+ - :exc:`InvalidArgument`
+ - :exc:`LoginFailure`
+ - :exc:`ConnectionClosed`
diff --git a/docs/conf.py b/docs/conf.py
index a1a11869..58c32c3f 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -36,7 +36,8 @@ extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'sphinxcontrib.asyncio',
- 'details'
+ 'details',
+ 'exception_hierarchy'
]
autodoc_member_order = 'bysource'
diff --git a/docs/ext/commands/api.rst b/docs/ext/commands/api.rst
index 0a919210..7dc46e08 100644
--- a/docs/ext/commands/api.rst
+++ b/docs/ext/commands/api.rst
@@ -214,8 +214,8 @@ Converters
.. _ext_commands_api_errors:
-Errors
--------
+Exceptions
+-----------
.. autoexception:: discord.ext.commands.CommandError
:members:
@@ -265,3 +265,25 @@ Errors
.. autoexception:: discord.ext.commands.BotMissingPermissions
:members:
+Exception Hierarchy
++++++++++++++++++++++
+
+.. exception_hierarchy::
+
+ - :exc:`~.DiscordException`
+ - :exc:`~.commands.CommandError`
+ - :exc:`~.commands.ConversionError`
+ - :exc:`~.commands.UserInputError`
+ - :exc:`~.commands.MissingRequiredArgument`
+ - :exc:`~.commands.TooManyArguments`
+ - :exc:`~.commands.BadArgument`
+ - :exc:`~.commands.BadUnionArgument`
+ - :exc:`~.commands.CommandNotFound`
+ - :exc:`~.commands.CheckFailure`
+ - :exc:`~.commands.NoPrivateMessage`
+ - :exc:`~.commands.NotOwner`
+ - :exc:`~.commands.MissingPermissions`
+ - :exc:`~.commands.BotMissingPermissions`
+ - :exc:`~.commands.DisabledCommand`
+ - :exc:`~.commands.CommandInvokeError`
+ - :exc:`~.commands.CommandOnCooldown`
diff --git a/docs/extensions/exception_hierarchy.py b/docs/extensions/exception_hierarchy.py
new file mode 100644
index 00000000..cc69a7ce
--- /dev/null
+++ b/docs/extensions/exception_hierarchy.py
@@ -0,0 +1,27 @@
+from docutils.parsers.rst import Directive
+from docutils.parsers.rst import states, directives
+from docutils.parsers.rst.roles import set_classes
+from docutils import nodes
+from sphinx.locale import _
+
+class exception_hierarchy(nodes.General, nodes.Element):
+ pass
+
+def visit_exception_hierarchy_node(self, node):
+ self.body.append(self.starttag(node, 'div', CLASS='exception-hierarchy-content'))
+
+def depart_exception_hierarchy_node(self, node):
+ self.body.append('</div>\n')
+
+class ExceptionHierarchyDirective(Directive):
+ has_content = True
+
+ def run(self):
+ self.assert_has_content()
+ node = exception_hierarchy('\n'.join(self.content))
+ self.state.nested_parse(self.content, self.content_offset, node)
+ return [node]
+
+def setup(app):
+ app.add_node(exception_hierarchy, html=(visit_exception_hierarchy_node, depart_exception_hierarchy_node))
+ app.add_directive('exception_hierarchy', ExceptionHierarchyDirective)