Skip to content

Commit 807364d

Browse files
committed
Start of exception docs
1 parent 0102e9f commit 807364d

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

docs/_extensions/exc_hierarchy.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from docutils.parsers.rst import Directive
2+
from docutils.parsers.rst import states, directives
3+
from docutils.parsers.rst.roles import set_classes
4+
from docutils import nodes
5+
from sphinx.locale import _
6+
7+
class exception_hierarchy(nodes.General, nodes.Element):
8+
pass
9+
10+
def visit_exception_hierarchy_node(self, node):
11+
self.body.append(self.starttag(node, 'div', CLASS='exception-hierarchy-content'))
12+
13+
def depart_exception_hierarchy_node(self, node):
14+
self.body.append('</div>\n')
15+
16+
class ExceptionHierarchyDirective(Directive):
17+
has_content = True
18+
19+
def run(self):
20+
self.assert_has_content()
21+
node = exception_hierarchy('\n'.join(self.content))
22+
self.state.nested_parse(self.content, self.content_offset, node)
23+
return [node]
24+
25+
def setup(app):
26+
app.add_node(exception_hierarchy, html=(visit_exception_hierarchy_node, depart_exception_hierarchy_node))
27+
app.add_directive('exception_hierarchy', ExceptionHierarchyDirective)
28+
return {'parallel_read_safe': True}

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"sphinxcontrib_trio",
5454
"sphinx_wagtail_theme",
5555
"aiter",
56+
"exc_hierarchy"
5657
]
5758

5859
# Add any paths that contain templates here, relative to this directory.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ References
6363
references/events
6464
references/user
6565
references/eventsub_subscriptions
66+
references/exceptions
6667

6768
.. toctree::
6869
:maxdepth: 1

docs/references/exceptions.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. currentmodule:: twitchio
2+
3+
4+
Exceptions
5+
----------
6+
7+
.. autoclass:: twitchio.TwitchioException
8+
9+
.. autoclass:: twitchio.HTTPException
10+
:members:
11+
12+
.. autoclass:: twitchio.InvalidTokenException
13+
:members:
14+
15+
16+
Exception Hierarchy
17+
~~~~~~~~~~~~~~~~~~~
18+
19+
.. exception_hierarchy::
20+
21+
- :exc:`TwitchioException`
22+
- :exc:`HTTPException`
23+
- :exc:`InvalidTokenException`

twitchio/exceptions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
from typing import TYPE_CHECKING, Any
2828

2929

30-
__all__ = ("HTTPException", "MessageRejectedError", "TwitchioException", "WebsocketConnectionException")
30+
__all__ = (
31+
"HTTPException",
32+
"MessageRejectedError",
33+
"TwitchioException",
34+
"WebsocketConnectionException",
35+
"InvalidTokenException",
36+
)
3137

3238

3339
if TYPE_CHECKING:

0 commit comments

Comments
 (0)