mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Add exception hierarchy to the documentation.
This commit is contained in:
parent
e15b4ef8e4
commit
13b23963ec
15
docs/_static/style.css
vendored
15
docs/_static/style.css
vendored
@ -322,6 +322,21 @@ div.helpful > p.admonition-title:after {
|
|||||||
content: unset;
|
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 {
|
pre {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
border: 1px solid #C6C9CB;
|
border: 1px solid #C6C9CB;
|
||||||
|
17
docs/api.rst
17
docs/api.rst
@ -2196,3 +2196,20 @@ The following exceptions are thrown by the library.
|
|||||||
.. autoexception:: discord.opus.OpusError
|
.. autoexception:: discord.opus.OpusError
|
||||||
|
|
||||||
.. autoexception:: discord.opus.OpusNotLoaded
|
.. 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`
|
||||||
|
@ -36,7 +36,8 @@ extensions = [
|
|||||||
'sphinx.ext.intersphinx',
|
'sphinx.ext.intersphinx',
|
||||||
'sphinx.ext.napoleon',
|
'sphinx.ext.napoleon',
|
||||||
'sphinxcontrib.asyncio',
|
'sphinxcontrib.asyncio',
|
||||||
'details'
|
'details',
|
||||||
|
'exception_hierarchy'
|
||||||
]
|
]
|
||||||
|
|
||||||
autodoc_member_order = 'bysource'
|
autodoc_member_order = 'bysource'
|
||||||
|
@ -214,8 +214,8 @@ Converters
|
|||||||
|
|
||||||
.. _ext_commands_api_errors:
|
.. _ext_commands_api_errors:
|
||||||
|
|
||||||
Errors
|
Exceptions
|
||||||
-------
|
-----------
|
||||||
|
|
||||||
.. autoexception:: discord.ext.commands.CommandError
|
.. autoexception:: discord.ext.commands.CommandError
|
||||||
:members:
|
:members:
|
||||||
@ -265,3 +265,25 @@ Errors
|
|||||||
.. autoexception:: discord.ext.commands.BotMissingPermissions
|
.. autoexception:: discord.ext.commands.BotMissingPermissions
|
||||||
:members:
|
: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`
|
||||||
|
27
docs/extensions/exception_hierarchy.py
Normal file
27
docs/extensions/exception_hierarchy.py
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user