1#!/usr/bin/env python
2
3# --------------------------------------------------------------------
4
5from petsc4py import PETSc
6
7# --------------------------------------------------------------------
8
9try:
10    from docutils.nodes import NodeVisitor
11    NodeVisitor.unknown_visit = lambda self, node: None
12    NodeVisitor.unknown_departure =  lambda self, node: None
13except ImportError:
14    pass
15
16try: # epydoc 3.0.1 + docutils 0.6
17    from docutils.nodes import Text
18    from UserString import UserString
19    if not isinstance(Text, UserString):
20        def Text_get_data(s):
21            try:
22                return s._data
23            except AttributeError:
24                return s.astext()
25        def Text_set_data(s, d):
26            s.astext = lambda: d
27            s._data = d
28        Text.data = property(Text_get_data, Text_set_data)
29except ImportError:
30    pass
31
32# --------------------------------------------------------------------
33
34from epydoc.docwriter import dotgraph
35
36import re
37dotgraph._DOT_VERSION_RE = \
38    re.compile(r'dot (?:- Graphviz )version ([\d\.]+)')
39
40try:
41
42    dotgraph.DotGraph.DEFAULT_HTML_IMAGE_FORMAT
43    dotgraph.DotGraph.DEFAULT_HTML_IMAGE_FORMAT = 'png'
44
45except AttributeError:
46
47    DotGraph_to_html = dotgraph.DotGraph.to_html
48    DotGraph_run_dot = dotgraph.DotGraph._run_dot
49
50    def to_html(self, image_file, image_url, center=True):
51        if image_file[-4:] == '.gif':
52            image_file = image_file[:-4] + '.png'
53        if image_url[-4:] == '.gif':
54            image_url = image_url[:-4] +  '.png'
55        return DotGraph_to_html(self, image_file, image_url)
56
57    def _run_dot(self, *options):
58        if '-Tgif' in options:
59            opts = list(options)
60            for i, o in enumerate(opts):
61                if o == '-Tgif': opts[i] = '-Tpng'
62            options = type(options)(opts)
63        return DotGraph_run_dot(self, *options)
64
65    dotgraph.DotGraph.to_html = to_html
66    dotgraph.DotGraph._run_dot = _run_dot
67
68# --------------------------------------------------------------------
69
70import re
71
72_SIGNATURE_RE = re.compile(
73    # Class name (for builtin methods)
74    r'^\s*((?P<class>\w+)\.)?' +
75    # The function name
76    r'(?P<func>\w+)' +
77    # The parameters
78    r'\(((?P<self>(?:self|cls|mcs)),?)?(?P<params>.*)\)' +
79    # The return value (optional)
80    r'(\s*(->)\s*(?P<return>\S.*?))?'+
81    # The end marker
82    r'\s*(\n|\s+(--|<=+>)\s+|$|\.\s+|\.\n)')
83
84from epydoc import docstringparser as dsp
85dsp._SIGNATURE_RE = _SIGNATURE_RE
86
87# --------------------------------------------------------------------
88
89import sys, os
90import epydoc.cli
91
92def epydocify():
93    dirname = os.path.dirname(__file__)
94    config = os.path.join(dirname, 'epydoc.cfg')
95    sys.argv.append('--config=' + config)
96    epydoc.cli.cli()
97
98if __name__ == '__main__':
99    epydocify()
100
101# --------------------------------------------------------------------
102