]>
git.saurik.com Git - wxWidgets.git/blob - misc/scripts/update_doc_libs.py
1 ##############################################################################
2 # Name: misc/scripts/update_doc_libs.py
3 # Purpose: Automatically insert \Library{} headers in the doc files
5 # RCS-ID: $Id: makeunixtags.sh 46320 2007-06-04 11:02:29Z VZ $
6 # Copyright: (c) 2007 Francesco Montorsi
7 # Licence: wxWindows licence
8 ##############################################################################
10 from update_doc_utils
import scanTexFiles
12 INCLUDE_PATH
="../../include"
14 def myCallback(classname
, texFileName
, content
, i
):
15 tofix
.add(texFileName
) # consider this .tex broken
17 # now search the include file for this class
19 for j
in range(i
,len(content
)):
21 if "wx/" in line
and ".h" in line
:
22 include
= line
[line
.find("wx/"):line
.find(".h")+2]
25 print " no include file declared for class %s" % classname
26 return True # go on with next \class
28 include
= include
.replace("\\_", "_")
29 print " the include file for %s is %s" % (classname
, include
)
31 # does this .tex already contains the \wxheading{Library} section nearby the include file?
32 for k
in range(j
,min(len(content
), j
+3)):
34 if "\wxheading{Library}" in line
:
35 print " this \class section already has its \wxheading{Library} section... skipping"
36 tofix
.remove(texFileName
) # was a valid .tex (at least for current class)
37 return True # go on with next \class
39 # now try to understand which lib contains this class
40 include
= INCLUDE_PATH
+ "/" + include
41 header
= open(include
, "r")
43 print " could not open %s" % include
44 return True # go on with next \class
47 content2
= header
.readlines()
49 # if they exist append port-specific headers contents
50 for c
in ["wx/gtk/", "wx/msw/", "wx/mac/", "wx/generic/"]:
52 temp
= include
.replace("wx/", c
)
53 print " trying to open %s..." % temp
54 header
= open(temp
, "r")
55 headercontents
= header
.readlines()
56 content2
= content2
+ headercontents
57 print " added %d lines from %s" % (len(headercontents
), temp
)
61 # now search for the export-declaration associated with this class
63 if "class " in line
and classname
in line
:
64 if line
.find("class") < line
.find(classname
): # could be a comment
66 decl
= line
[line
.find("_")+1:]
67 decl
= decl
[:decl
.find(" ")]
68 decl
= decl
.replace("FWD_", "")
69 decl
= decl
[0:1].upper() + decl
[1:].lower()
71 elif " WXDLLEXPORT " in line
:
76 print " no declaration associated with %s" % classname
77 return True # go on with next \class
79 print " the declaration associated with %s is %s" % (classname
, decl
)
80 tofix
.remove(texFileName
) # was a valid .tex (at least for current class)
82 # now modify the .tex file
83 content
.insert(j
+2, "\wxheading{Library}\n\n\helpref{wx%s}{librarieslist}\n\n" % decl
)
86 file = open(texFileName
, "w")
87 file.write(''.join(content
))
90 print " updated %s" % texFileName
97 count
= scanTexFiles(myCallback
)
99 print "\nProcessed %d files, automatically fixed %d files." % (count
, fixed
)
100 print "There are %d files to fix manually:\n%s" % (len(tofix
), '\n'.join(tofix
))