Passed
Pull Request — main (#155)
by Oliver
01:45
created

visit_exception_hierarchy_node()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 2
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
8
class exception_hierarchy(nodes.General, nodes.Element):
9
    pass
10
11
12
def visit_exception_hierarchy_node(self, node):
13
    self.starttag(
14
        node, 'div', CLASS='exception-hierarchy-content'
15
    )
16
17
18
def depart_exception_hierarchy_node(self, node):
19
    self.body.append('</div>\n')
20
21
22
class ExceptionHierarchyDirective(Directive):
23
    has_content = True
24
25
    def run(self):
26
        self.assert_has_content()
27
        node = exception_hierarchy('\n'.join(self.content))
28
        self.state.nested_parse(self.content, self.content_offset, node)
29
        return [node]
30
31
32
def setup(app):
33
    app.add_node(exception_hierarchy, html=(
34
        visit_exception_hierarchy_node, depart_exception_hierarchy_node))
35
    app.add_directive('exception_hierarchy', ExceptionHierarchyDirective)
36