~ubuntu-branches/ubuntu/natty/sphinx/natty

« back to all changes in this revision

Viewing changes to sphinx/ext/ifconfig.py

  • Committer: Bazaar Package Importer
  • Author(s): Mikhail Gusarov, Mikhail Gusarov, Piotr Ożarowski
  • Date: 2009-04-12 14:37:30 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090412143730-nb04j8o5cul2cquo
Tags: 0.6.1-2
[ Mikhail Gusarov ]
* Fix debian/README.source: s/dpatch/quilt/ (Closes: #523293).
* Add debian/rfind-invocation.patch, fixing breakage on python-werkzeug
  docs.

[ Piotr Ożarowski ]
* Install .mo files (Closes: #526027)

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
           This stuff is only included in the built docs for unstable versions.
14
14
 
15
15
    The argument for ``ifconfig`` is a plain Python expression, evaluated in the
16
 
    namespace of the project configuration (that is, all variables from ``conf.py``
17
 
    are available.)
 
16
    namespace of the project configuration (that is, all variables from
 
17
    ``conf.py`` are available.)
18
18
 
19
19
    :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
20
20
    :license: BSD, see LICENSE for details.
22
22
 
23
23
from docutils import nodes
24
24
 
 
25
from sphinx.util.compat import Directive
 
26
 
25
27
 
26
28
class ifconfig(nodes.Element): pass
27
29
 
28
30
 
29
 
def ifconfig_directive(name, arguments, options, content, lineno,
30
 
                       content_offset, block_text, state, state_machine):
31
 
    node = ifconfig()
32
 
    node.line = lineno
33
 
    node['expr'] = arguments[0]
34
 
    state.nested_parse(content, content_offset, node)
35
 
    return [node]
 
31
class IfConfig(Directive):
 
32
 
 
33
    has_content = True
 
34
    required_arguments = 1
 
35
    optional_arguments = 0
 
36
    final_argument_whitespace = True
 
37
    option_spec = {}
 
38
 
 
39
    def run(self):
 
40
        node = ifconfig()
 
41
        node.document = self.state.document
 
42
        node.line = self.lineno
 
43
        node['expr'] = self.arguments[0]
 
44
        self.state.nested_parse(self.content, self.content_offset, node)
 
45
        return [node]
36
46
 
37
47
 
38
48
def process_ifconfig_nodes(app, doctree, docname):
58
68
 
59
69
def setup(app):
60
70
    app.add_node(ifconfig)
61
 
    app.add_directive('ifconfig', ifconfig_directive, 1, (1, 0, 1))
 
71
    app.add_directive('ifconfig', IfConfig)
62
72
    app.connect('doctree-resolved', process_ifconfig_nodes)