| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |