]>
git.saurik.com Git - wxWidgets.git/blob - misc/scripts/update_doc_libs.py
3a57056ca22fa8297c3b59572d4074acef0ee326
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 import sys
, os
, glob
, distutils
.file_util
14 for f
in glob
.glob('*.tex'):
17 print "could not open %s" % f
19 print "opened file %s" % f
23 content
= file.readlines()
25 for i
in range(len(content
)):
28 classdecl
= classdecl
+ 1
31 classname
= classname
[classname
.find("\class{"):]
32 classname
= classname
[classname
.find("{")+1:classname.find("}")]
33 print " the class declared is named '%s'" % classname
35 tofix
.add(f
) # consider this .tex broken
37 # now search the include file for this class
39 for j
in range(i
,len(content
)):
41 if "wx/" in line
and ".h" in line
:
42 include
= line
[line
.find("wx/"):line
.find(".h")+2]
45 print " no include file declared for class %s" % classname
48 include
= include
.replace("\\_", "_")
49 print " the include file for %s is %s" % (classname
, include
)
51 # now try to understand which libs contains this class
52 include
= "../../../include/" + include
53 header
= open(include
, "r")
55 print " could not open %s" % include
59 content2
= header
.readlines()
61 # if they exist append port-specific headers contents
62 for c
in ["wx/gtk/", "wx/msw/", "wx/mac/", "wx/generic/"]:
64 temp
= include
.replace("wx/", c
)
65 print " trying to open %s..." % temp
66 header
= open(temp
, "r")
67 headercontents
= header
.readlines()
68 content2
= content2
+ headercontents
69 print " added %d lines from %s" % (len(headercontents
), temp
)
74 if "class " in line
and classname
in line
:
75 if line
.find("class") < line
.find(classname
): # could be a comment
77 decl
= line
[line
.find("_")+1:]
78 decl
= decl
[:decl
.find(" ")]
79 decl
= decl
.replace("FWD_", "")
80 decl
= decl
[0:1].upper() + decl
[1:].lower()
82 elif " WXDLLEXPORT " in line
:
87 print " no declaration associated with %s" % classname
90 print " the declaration associated with %s is %s" % (classname
, decl
)
91 tofix
.remove(f
) # was a valid .tex (at least for current class)
93 # now modify the .tex file
94 content
.insert(j
+2, "\wxheading{Library}\n\n\helpref{wx%s}{librarieslist}\n\n" % decl
)
98 file.write(''.join(content
))
103 print " updated %s" % f
106 print " file %s contains %d class declarations" % (f
, classdecl
)
108 print "\nProcessed %d files." % count
109 print "There are %d files to fix:\n%s" % (len(tofix
), '\n'.join(tofix
))