summaryrefslogtreecommitdiff
path: root/sphinx/ext/ifconfig.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-02-18 21:48:00 +0100
committerGeorg Brandl <georg@python.org>2009-02-18 21:48:00 +0100
commit3c566ba9734c38825a4cfc2bcbfee106248efd25 (patch)
tree614b4d66284678956e536440c67b7ef8e9b5715e /sphinx/ext/ifconfig.py
parentd44f67e3afd6f788fc84a770970c6f1eb13be580 (diff)
downloadsphinx-3c566ba9734c38825a4cfc2bcbfee106248efd25.tar.gz
Convert directives in builtin extensions to class API.
Diffstat (limited to 'sphinx/ext/ifconfig.py')
-rw-r--r--sphinx/ext/ifconfig.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py
index af3975b8..90cd2b2c 100644
--- a/sphinx/ext/ifconfig.py
+++ b/sphinx/ext/ifconfig.py
@@ -22,17 +22,27 @@
from docutils import nodes
+from sphinx.util.compat import Directive
+
class ifconfig(nodes.Element): pass
-def ifconfig_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- node = ifconfig()
- node.line = lineno
- node['expr'] = arguments[0]
- state.nested_parse(content, content_offset, node)
- return [node]
+class IfConfig(Directive):
+
+ has_content = True
+ required_arguments = 1
+ optional_arguments = 0
+ final_argument_whitespace = True
+ option_spec = {}
+
+ def run(self):
+ node = ifconfig()
+ node.document = self.state.document
+ node.line = self.lineno
+ node['expr'] = self.arguments[0]
+ self.state.nested_parse(self.content, self.content_offset, node)
+ return [node]
def process_ifconfig_nodes(app, doctree, docname):
@@ -58,5 +68,5 @@ def process_ifconfig_nodes(app, doctree, docname):
def setup(app):
app.add_node(ifconfig)
- app.add_directive('ifconfig', ifconfig_directive, 1, (1, 0, 1))
+ app.add_directive('ifconfig', IfConfig)
app.connect('doctree-resolved', process_ifconfig_nodes)