aboutsummaryrefslogtreecommitdiffstats
path: root/docs/cryptography-docs.py
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2013-10-29 19:02:51 -0700
committerDonald Stufft <donald@stufft.io>2013-10-29 19:02:51 -0700
commit6f6d6087cf5747629d51bca3333e6c2be91ca28b (patch)
tree6bc1c563bd230dd74d6052d5f8ee6ddf8213a169 /docs/cryptography-docs.py
parentacfdd61e8e67b8d2df2d4662631e8f8e1c1bc0c0 (diff)
parentb8be0e9a6363d94d32eecaeb6eacfb9168839338 (diff)
downloadcryptography-6f6d6087cf5747629d51bca3333e6c2be91ca28b.tar.gz
cryptography-6f6d6087cf5747629d51bca3333e6c2be91ca28b.tar.bz2
cryptography-6f6d6087cf5747629d51bca3333e6c2be91ca28b.zip
Merge pull request #195 from alex/sphinx-hazmat-plugin
Sphinx hazmat plugin
Diffstat (limited to 'docs/cryptography-docs.py')
-rw-r--r--docs/cryptography-docs.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/cryptography-docs.py b/docs/cryptography-docs.py
new file mode 100644
index 00000000..4ed5526a
--- /dev/null
+++ b/docs/cryptography-docs.py
@@ -0,0 +1,47 @@
+from docutils import nodes
+
+from sphinx.util.compat import Directive, make_admonition
+
+
+DANGER_MESSAGE = """
+This is a "Hazardous Materials" module. You should **ONLY** use it if you're
+100% absolutely sure that you know what you're doing because this module is
+full of land mines, dragons, and dinosaurs with laser guns. """
+
+
+class HazmatDirective(Directive):
+ def run(self):
+ ad = make_admonition(
+ Hazmat,
+ self.name,
+ [],
+ self.options,
+ nodes.paragraph("", DANGER_MESSAGE),
+ self.lineno,
+ self.content_offset,
+ self.block_text,
+ self.state,
+ self.state_machine
+ )
+ ad[0].line = self.lineno
+ return ad
+
+
+class Hazmat(nodes.Admonition, nodes.Element):
+ pass
+
+
+def visit_hazmat_node(self, node):
+ return self.visit_admonition(node, "danger")
+
+
+def depart_hazmat_node(self, node):
+ return self.depart_admonition(node)
+
+
+def setup(app):
+ app.add_node(
+ Hazmat,
+ html=(visit_hazmat_node, depart_hazmat_node)
+ )
+ app.add_directive("hazmat", HazmatDirective)