PLplot
5.15.0
Toggle main menu visibility
Loading...
Searching...
No Matches
makedocstrings.py
Go to the documentation of this file.
1
# Copyright 2002 Gary Bishop
2
# This file is part of PLplot.
3
4
# PLplot is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU Library General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
7
8
# PLplot is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Library General Public License for more details.
12
13
# You should have received a copy of the GNU Library General Public License
14
# along with the file PLplot; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17
# The recent versions of SWIG (at least for 1.3.11) do not handle documentation
18
# strings correctly
19
# This script is a quick hack to fixup the doc strings in the
20
# SWIG-generated c code, but presumably this script
21
# will not always be necessary
22
23
import
sys, re
24
25
def
main
():
26
if
len(sys.argv) != 3:
27
print
'usage: makedocstrings infile outfile'
28
29
infile = open(sys.argv[1],
'rt'
)
30
outfile = open(sys.argv[2],
'wt'
)
31
32
docstrings = {}
33
34
while
1:
35
line = infile.readline()
36
if
not
line:
37
break
38
m = re.match(
r'#define _doc_([a-zA-Z_0-9]+)'
, line)
39
if
m:
40
name = m.group(1)
41
value =
'_doc_'
+name
42
docstrings[name] = value
43
#print 'got',name
44
45
if
re.match(
r'static PyMethodDef SwigMethods'
, line):
46
outfile.write(line)
47
#print 'here'
48
while
1:
49
line = infile.readline()
50
m = re.match(
'[ \t]+\{[ \t]\(char \*\)"([a-zA-Z_0-9]+)"(.*)\,[ ]*NULL[ ]*\},'
, line)
51
if
not
m:
52
m = re.match(
'[ \t]+\{[ \t]\(char \*\)"([a-zA-Z_0-9]+)"(.*)\},'
, line)
53
if
not
m:
54
break
55
func = m.group(1)
56
#print 'look for',func
57
if
func
in
docstrings.keys():
58
line =
'\t{ (char *)"%s"%s, %s },\n'
% (func, m.group(2), docstrings[func])
59
outfile.write(line)
60
61
outfile.write(line)
62
63
if
__name__ ==
'__main__'
:
64
main
()
makedocstrings.main
main()
Definition
makedocstrings.py:25
bindings
python
makedocstrings.py
Generated on
for PLplot by
1.17.0