blob: 4ed5526af9a6fec228a0c2d2ad22e58ea4bc3548 [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
34def visit_hazmat_node(self, node):
35 return self.visit_admonition(node, "danger")
36
37
38def depart_hazmat_node(self, node):
39 return self.depart_admonition(node)
40
41
42def setup(app):
43 app.add_node(
44 Hazmat,
45 html=(visit_hazmat_node, depart_hazmat_node)
46 )
47 app.add_directive("hazmat", HazmatDirective)