blob: ea7e8eef5beb62e8c89769ff1159a58af5a177bb [file] [log] [blame]
Alex Gaynoraf82d5e2013-10-29 17:07:24 -07001from docutils import nodes
2
3from sphinx.util.compat import Directive, make_admonition
4
5
6DANGER_MESSAGE = """
7This is a "Hazardous Materials" module. You should **ONLY** use it if you're
8100% absolutely sure that you know what you're doing because this module is
9full of land mines, dragons, and dinosaurs with laser guns. """
10
Alex Gaynorb8be0e92013-10-29 18:10:03 -070011
Alex Gaynoraf82d5e2013-10-29 17:07:24 -070012class HazmatDirective(Directive):
13 def run(self):
14 ad = make_admonition(
15 Hazmat,
16 self.name,
17 [],
18 self.options,
19 nodes.paragraph("", DANGER_MESSAGE),
20 self.lineno,
21 self.content_offset,
22 self.block_text,
23 self.state,
24 self.state_machine
25 )
26 ad[0].line = self.lineno
27 return ad
28
29
30class Hazmat(nodes.Admonition, nodes.Element):
31 pass
32
33
Alex Gaynor69f5ee42013-11-19 14:06:18 -080034def html_visit_hazmat_node(self, node):
Alex Gaynoraf82d5e2013-10-29 17:07:24 -070035 return self.visit_admonition(node, "danger")
36
37
Alex Gaynor69f5ee42013-11-19 14:06:18 -080038def latex_visit_hazmat_node(self, node):
39 return self.visit_admonition(node)
40
41
Alex Gaynoraf82d5e2013-10-29 17:07:24 -070042def depart_hazmat_node(self, node):
43 return self.depart_admonition(node)
44
45
46def setup(app):
47 app.add_node(
48 Hazmat,
Alex Gaynor69f5ee42013-11-19 14:06:18 -080049 html=(html_visit_hazmat_node, depart_hazmat_node),
50 latex=(latex_visit_hazmat_node, depart_hazmat_node),
Alex Gaynoraf82d5e2013-10-29 17:07:24 -070051 )
52 app.add_directive("hazmat", HazmatDirective)