-
Notifications
You must be signed in to change notification settings - Fork 0
/
epydocify.py
executable file
·112 lines (85 loc) · 2.96 KB
/
epydocify.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
# --------------------------------------------------------------------
import sys
sys.path.append('..')
import mpi4py.MPI
import ga
try:
from signal import signal, SIGPIPE, SIG_IGN
signal(SIGPIPE, SIG_IGN)
except ImportError:
pass
# --------------------------------------------------------------------
try:
from docutils.nodes import NodeVisitor
NodeVisitor.unknown_visit = lambda self, node: None
NodeVisitor.unknown_departure = lambda self, node: None
except ImportError:
pass
try: # epydoc 3.0.1 + docutils 0.6
from docutils.nodes import Text
from UserString import UserString
if not isinstance(Text, UserString):
def Text_get_data(s):
try:
return s._data
except AttributeError:
return s.astext()
def Text_set_data(s, d):
s.astext = lambda: d
s._data = d
Text.data = property(Text_get_data, Text_set_data)
except ImportError:
pass
# --------------------------------------------------------------------
from epydoc.docwriter import dotgraph
import re
dotgraph._DOT_VERSION_RE = \
re.compile(r'dot (?:- Graphviz )version ([\d\.]+)')
try:
dotgraph.DotGraph.DEFAULT_HTML_IMAGE_FORMAT
dotgraph.DotGraph.DEFAULT_HTML_IMAGE_FORMAT = 'png'
except AttributeError:
DotGraph_to_html = dotgraph.DotGraph.to_html
DotGraph_run_dot = dotgraph.DotGraph._run_dot
def to_html(self, image_file, image_url, center=True):
if image_file[-4:] == '.gif':
image_file = image_file[:-4] + '.png'
if image_url[-4:] == '.gif':
image_url = image_url[:-4] + '.png'
return DotGraph_to_html(self, image_file, image_url)
def _run_dot(self, *options):
if '-Tgif' in options:
opts = list(options)
for i, o in enumerate(opts):
if o == '-Tgif': opts[i] = '-Tpng'
options = type(options)(opts)
return DotGraph_run_dot(self, *options)
dotgraph.DotGraph.to_html = to_html
dotgraph.DotGraph._run_dot = _run_dot
# --------------------------------------------------------------------
import re
_SIGNATURE_RE = re.compile(
# Class name (for builtin methods)
r'^\s*((?P<class>\w+)\.)?' +
# The function name
r'(?P<func>\w+)' +
# The parameters
r'\(((?P<self>(?:self|cls|mcs)),?)?(?P<params>.*)\)' +
# The return value (optional)
r'(\s*(->)\s*(?P<return>\S.*?))?'+
# The end marker
r'\s*(\n|\s+(--|<=+>)\s+|$|\.\s+|\.\n)')
from epydoc import docstringparser as dsp
dsp._SIGNATURE_RE = _SIGNATURE_RE
# --------------------------------------------------------------------
import sys, os
import epydoc.cli
def epydocify():
dirname = os.path.dirname(__file__)
config = os.path.join(dirname, 'epydoc.cfg')
sys.argv.append('--config=' + config)
epydoc.cli.cli()
if __name__ == '__main__':
epydocify()
# --------------------------------------------------------------------