| 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(node, "div", CLASS="exception-hierarchy-content") |
||
| 14 | |||
| 15 | |||
| 16 | def depart_exception_hierarchy_node(self, node): |
||
| 17 | self.body.append("</div>\n") |
||
| 18 | |||
| 19 | |||
| 20 | class ExceptionHierarchyDirective(Directive): |
||
| 21 | has_content = True |
||
| 22 | |||
| 23 | def run(self): |
||
| 24 | self.assert_has_content() |
||
| 25 | node = exception_hierarchy("\n".join(self.content)) |
||
| 26 | self.state.nested_parse(self.content, self.content_offset, node) |
||
| 27 | return [node] |
||
| 28 | |||
| 29 | |||
| 30 | def setup(app): |
||
| 31 | app.add_node( |
||
| 32 | exception_hierarchy, |
||
| 33 | html=(visit_exception_hierarchy_node, depart_exception_hierarchy_node), |
||
| 34 | ) |
||
| 35 | app.add_directive("exception_hierarchy", ExceptionHierarchyDirective) |
||
| 36 |