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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
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.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.napoleon',
|
||||
'sphinxcontrib.asyncio',
|
||||
'details'
|
||||
'details',
|
||||
'exception_hierarchy'
|
||||
]
|
||||
|
||||
autodoc_member_order = 'bysource'
|
||||
|
@ -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`
|
||||
|
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