aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/mgext/youcanhelp.py
blob: a99d0e4df39d18d618ac6a2a050ecd2f8c75eda8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from docutils import nodes

from sphinx.util.compat import Directive, make_admonition

class youcanhelp_node(nodes.Admonition, nodes.Element):
    pass

class YouCanHelp(Directive):
    has_content = True
    required_arguments = 0
    optional_arguments = 0
    final_argument_whitespace = False
    option_spec = {}

    def run(self):
        ad = make_admonition(
            youcanhelp_node,
            self.name,
            ["You Can Help!"],
            self.options,
            self.content,
            self.lineno,
            self.content_offset,
            self.block_text,
            self.state,
            self.state_machine)
        ad[0].line = self.lineno
        return ad

def visit_youcanhelp_node(self, node):
    self.visit_admonition(node)

def depart_youcanhelp_node(self, node):
    self.depart_admonition(node)

def setup(app):
    app.add_node(
        youcanhelp_node,
        html=(visit_youcanhelp_node, depart_youcanhelp_node),
        latex=(visit_youcanhelp_node, depart_youcanhelp_node),
        text=(visit_youcanhelp_node, depart_youcanhelp_node)
        )
    
    app.add_directive('youcanhelp', YouCanHelp)