use svn:eol-style instead of eol:style (see #10745)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60398 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-04-26 19:36:36 +00:00
parent 0e16e5c3b4
commit 61f2782a32
3 changed files with 279 additions and 279 deletions

View File

@@ -1,130 +1,130 @@
############################################################################## ##############################################################################
# Name: misc/scripts/update_doc_baseclasses.py # Name: misc/scripts/update_doc_baseclasses.py
# Purpose: Warns about missing classes in the "Derived from" # Purpose: Warns about missing classes in the "Derived from"
# sections in the doc files # sections in the doc files
# Created: 2007-07-28 # Created: 2007-07-28
# RCS-ID: $Id: makeunixtags.sh 46320 2007-06-04 11:02:29Z VZ $ # RCS-ID: $Id: makeunixtags.sh 46320 2007-06-04 11:02:29Z VZ $
# Copyright: (c) 2007 Francesco Montorsi # Copyright: (c) 2007 Francesco Montorsi
# Licence: wxWindows licence # Licence: wxWindows licence
############################################################################## ##############################################################################
from update_doc_utils import scanTexFiles from update_doc_utils import scanTexFiles
# classes whose docs cannot be fixed automatically # classes whose docs cannot be fixed automatically
# because of: # because of:
# 1) multiple inheritance # 1) multiple inheritance
# 2) other strange things specific of these classes # 2) other strange things specific of these classes
EXCEPTIONS=['wxNotebook','wxChoicebook','wxListbook','wxToolbook','wxTreebook','wxURLDataObject','wxHScrolledWindow','wxVScrolledWindow','wxVarHVScrollHelper','wxHVScrolledWindow','wxFileStream'] EXCEPTIONS=['wxNotebook','wxChoicebook','wxListbook','wxToolbook','wxTreebook','wxURLDataObject','wxHScrolledWindow','wxVScrolledWindow','wxVarHVScrollHelper','wxHVScrolledWindow','wxFileStream']
def myCallback(classname, texFileName, content, i): def myCallback(classname, texFileName, content, i):
# now search the base classes for this class # now search the base classes for this class
baseclasses = [] baseclasses = []
for j in range(i,len(content)): for j in range(i,len(content)):
line = content[j] line = content[j]
if line.startswith("\wxheading{Derived from}"): if line.startswith("\wxheading{Derived from}"):
# take all lines contained between this \wxheading and the next one # take all lines contained between this \wxheading and the next one
# as base classes # as base classes
for k in range(j+1,len(content)): for k in range(j+1,len(content)):
line = content[k] line = content[k]
if "\wxheading" in line: if "\wxheading" in line:
break break
elif "\helpref" in line: elif "\helpref" in line:
baseclasses.append(line) baseclasses.append(line)
break # we've already processed the 'derived from' section for this class break # we've already processed the 'derived from' section for this class
if baseclasses == []: if baseclasses == []:
print " no base classes declared for class %s" % classname print " no base classes declared for class %s" % classname
return True # keep going on with next \class tags return True # keep going on with next \class tags
# polish baseclasses list # polish baseclasses list
for i in range(len(baseclasses)): for i in range(len(baseclasses)):
s = baseclasses[i] s = baseclasses[i]
baseclasses[i] = s[s.find("{")+1:s.find("}")] baseclasses[i] = s[s.find("{")+1:s.find("}")]
# store the baseclasses # store the baseclasses
tree[classname] = baseclasses tree[classname] = baseclasses
treetex[classname] = texFileName treetex[classname] = texFileName
treepos[classname] = j+1 treepos[classname] = j+1
print " class '%s' has %d base class(es): %s" % (classname, len(baseclasses), ','.join(baseclasses)) print " class '%s' has %d base class(es): %s" % (classname, len(baseclasses), ','.join(baseclasses))
return True return True
tree = dict() tree = dict()
treetex = dict() treetex = dict()
treepos = dict() treepos = dict()
count = scanTexFiles(myCallback) count = scanTexFiles(myCallback)
print "\nProcessed %d files." % count print "\nProcessed %d files." % count
print "\nNow starting to compare the base class lists.\n" print "\nNow starting to compare the base class lists.\n"
def getFullListOfBaseClasses(classname): def getFullListOfBaseClasses(classname):
if classname not in tree or classname=='': if classname not in tree or classname=='':
return [] return []
# only use the first base class of info taken from .tex files # only use the first base class of info taken from .tex files
# i.e. we assume that at least the first class declared as base class is always correct # i.e. we assume that at least the first class declared as base class is always correct
baseclass = tree[classname][0] baseclass = tree[classname][0]
return [baseclass] + getFullListOfBaseClasses(baseclass) return [baseclass] + getFullListOfBaseClasses(baseclass)
# now compare the theorical list of base classes with the list of base # now compare the theorical list of base classes with the list of base
# classes taken from the .tex files # classes taken from the .tex files
fixed=0 fixed=0
tofix=set() tofix=set()
for classname in tree: for classname in tree:
theorical=getFullListOfBaseClasses(classname) theorical=getFullListOfBaseClasses(classname)
real=tree[classname] real=tree[classname]
# compare them # compare them
if real!=theorical: if real!=theorical:
print "* for class '%s' documented in '%s'" % (classname,treetex[classname]) print "* for class '%s' documented in '%s'" % (classname,treetex[classname])
print " theorical list: %s" % theorical print " theorical list: %s" % theorical
print " declared list: %s" % real print " declared list: %s" % real
if classname in EXCEPTIONS: if classname in EXCEPTIONS:
tofix.add(treetex[classname]) tofix.add(treetex[classname])
print " cannot fix automatically (blacklisted class!)\n" print " cannot fix automatically (blacklisted class!)\n"
continue continue
# fix it! # fix it!
file = open(treetex[classname], "r") file = open(treetex[classname], "r")
content = file.readlines() content = file.readlines()
#print "old content is:" #print "old content is:"
#print ''.join(content) #print ''.join(content)
# remove old \helpref lines # remove old \helpref lines
startidx = treepos[classname] startidx = treepos[classname]
count = 0 count = 0
while count < len(tree[classname]): while count < len(tree[classname]):
# we want to remove n \helpref lines, where 'n' is the # we want to remove n \helpref lines, where 'n' is the
# number of base classes declared # number of base classes declared
if content[startidx].startswith('\helpref'): if content[startidx].startswith('\helpref'):
del content[startidx] del content[startidx]
count = count+1 count = count+1
else: else:
startidx = startidx+1 # probably an empty line startidx = startidx+1 # probably an empty line
# insert new ones # insert new ones
if len(theorical)>1: if len(theorical)>1:
for j in range(len(theorical)-1): for j in range(len(theorical)-1):
c = theorical[j] c = theorical[j]
content.insert(startidx+j, "\helpref{%s}{%s}\\\\\n" % (c, c.lower())) content.insert(startidx+j, "\helpref{%s}{%s}\\\\\n" % (c, c.lower()))
else: else:
j=-1 j=-1
c = theorical[j+1] c = theorical[j+1]
content.insert(startidx+j+1, "\helpref{%s}{%s}\n" % (c, c.lower())) content.insert(startidx+j+1, "\helpref{%s}{%s}\n" % (c, c.lower()))
#print "new content is:" #print "new content is:"
#print ''.join(content) #print ''.join(content)
# save the file # save the file
file = open(treetex[classname], "w") file = open(treetex[classname], "w")
file.write(''.join(content)) file.write(''.join(content))
file.flush() file.flush()
print " fixed the .tex file\n" print " fixed the .tex file\n"
fixed=fixed+1 fixed=fixed+1
print "Total number of errors reported: %d" % fixed print "Total number of errors reported: %d" % fixed
print "There are %d files to fix manually:\n%s" % (len(tofix), '\n'.join(tofix)) print "There are %d files to fix manually:\n%s" % (len(tofix), '\n'.join(tofix))

View File

@@ -1,100 +1,100 @@
############################################################################## ##############################################################################
# Name: misc/scripts/update_doc_libs.py # Name: misc/scripts/update_doc_libs.py
# Purpose: Automatically insert \Library{} headers in the doc files # Purpose: Automatically insert \Library{} headers in the doc files
# Created: 2007-07-28 # Created: 2007-07-28
# RCS-ID: $Id: makeunixtags.sh 46320 2007-06-04 11:02:29Z VZ $ # RCS-ID: $Id: makeunixtags.sh 46320 2007-06-04 11:02:29Z VZ $
# Copyright: (c) 2007 Francesco Montorsi # Copyright: (c) 2007 Francesco Montorsi
# Licence: wxWindows licence # Licence: wxWindows licence
############################################################################## ##############################################################################
from update_doc_utils import scanTexFiles from update_doc_utils import scanTexFiles
INCLUDE_PATH="../../include" INCLUDE_PATH="../../include"
def myCallback(classname, texFileName, content, i): def myCallback(classname, texFileName, content, i):
tofix.add(texFileName) # consider this .tex broken tofix.add(texFileName) # consider this .tex broken
# now search the include file for this class # now search the include file for this class
include = "" include = ""
for j in range(i,len(content)): for j in range(i,len(content)):
line = content[j] line = content[j]
if "wx/" in line and ".h" in line: if "wx/" in line and ".h" in line:
include = line[line.find("wx/"):line.find(".h")+2] include = line[line.find("wx/"):line.find(".h")+2]
break break
if include == "": if include == "":
print " no include file declared for class %s" % classname print " no include file declared for class %s" % classname
return True # go on with next \class return True # go on with next \class
include = include.replace("\\_", "_") include = include.replace("\\_", "_")
print " the include file for %s is %s" % (classname, include) print " the include file for %s is %s" % (classname, include)
# does this .tex already contains the \wxheading{Library} section nearby the include file? # does this .tex already contains the \wxheading{Library} section nearby the include file?
for k in range(j,min(len(content), j+3)): for k in range(j,min(len(content), j+3)):
line = content[k] line = content[k]
if "\wxheading{Library}" in line: if "\wxheading{Library}" in line:
print " this \class section already has its \wxheading{Library} section... skipping" print " this \class section already has its \wxheading{Library} section... skipping"
tofix.remove(texFileName) # was a valid .tex (at least for current class) tofix.remove(texFileName) # was a valid .tex (at least for current class)
return True # go on with next \class return True # go on with next \class
# now try to understand which lib contains this class # now try to understand which lib contains this class
include = INCLUDE_PATH + "/" + include include = INCLUDE_PATH + "/" + include
header = open(include, "r") header = open(include, "r")
if not header: if not header:
print " could not open %s" % include print " could not open %s" % include
return True # go on with next \class return True # go on with next \class
decl = "" decl = ""
content2 = header.readlines() content2 = header.readlines()
# if they exist append port-specific headers contents # if they exist append port-specific headers contents
for c in ["wx/gtk/", "wx/msw/", "wx/mac/", "wx/generic/"]: for c in ["wx/gtk/", "wx/msw/", "wx/mac/", "wx/generic/"]:
try: try:
temp = include.replace("wx/", c) temp = include.replace("wx/", c)
print " trying to open %s..." % temp print " trying to open %s..." % temp
header = open(temp, "r") header = open(temp, "r")
headercontents = header.readlines() headercontents = header.readlines()
content2 = content2 + headercontents content2 = content2 + headercontents
print " added %d lines from %s" % (len(headercontents), temp) print " added %d lines from %s" % (len(headercontents), temp)
except: except:
pass pass
# now search for the export-declaration associated with this class # now search for the export-declaration associated with this class
for line in content2: for line in content2:
if "class " in line and classname in line: if "class " in line and classname in line:
if line.find("class") < line.find(classname): # could be a comment if line.find("class") < line.find(classname): # could be a comment
if "_" in line: if "_" in line:
decl = line[line.find("_")+1:] decl = line[line.find("_")+1:]
decl = decl[:decl.find(" ")] decl = decl[:decl.find(" ")]
decl = decl.replace("FWD_", "") decl = decl.replace("FWD_", "")
decl = decl[0:1].upper() + decl[1:].lower() decl = decl[0:1].upper() + decl[1:].lower()
break break
elif " WXDLLEXPORT " in line: elif " WXDLLEXPORT " in line:
decl = "Core" decl = "Core"
break break
if decl == "": if decl == "":
print " no declaration associated with %s" % classname print " no declaration associated with %s" % classname
return True # go on with next \class return True # go on with next \class
print " the declaration associated with %s is %s" % (classname, decl) print " the declaration associated with %s is %s" % (classname, decl)
tofix.remove(texFileName) # was a valid .tex (at least for current class) tofix.remove(texFileName) # was a valid .tex (at least for current class)
# now modify the .tex file # now modify the .tex file
content.insert(j+2, "\wxheading{Library}\n\n\helpref{wx%s}{librarieslist}\n\n" % decl) content.insert(j+2, "\wxheading{Library}\n\n\helpref{wx%s}{librarieslist}\n\n" % decl)
# write it # write it
file = open(texFileName, "w") file = open(texFileName, "w")
file.write(''.join(content)) file.write(''.join(content))
file.flush() file.flush()
print " updated %s" % texFileName print " updated %s" % texFileName
fixed = fixed+1 fixed = fixed+1
return True return True
fixed = 0 fixed = 0
tofix = set() tofix = set()
count = scanTexFiles(myCallback) count = scanTexFiles(myCallback)
print "\nProcessed %d files, automatically fixed %d files." % (count, fixed) print "\nProcessed %d files, automatically fixed %d files." % (count, fixed)
print "There are %d files to fix manually:\n%s" % (len(tofix), '\n'.join(tofix)) print "There are %d files to fix manually:\n%s" % (len(tofix), '\n'.join(tofix))

View File

@@ -1,49 +1,49 @@
############################################################################## ##############################################################################
# Name: misc/scripts/update_doc_utils.py # Name: misc/scripts/update_doc_utils.py
# Purpose: base utilities for others update_doc_*.py scripts # Purpose: base utilities for others update_doc_*.py scripts
# Created: 2007-08-1 # Created: 2007-08-1
# RCS-ID: $Id: makeunixtags.sh 46320 2007-06-04 11:02:29Z VZ $ # RCS-ID: $Id: makeunixtags.sh 46320 2007-06-04 11:02:29Z VZ $
# Copyright: (c) 2007 Francesco Montorsi # Copyright: (c) 2007 Francesco Montorsi
# Licence: wxWindows licence # Licence: wxWindows licence
############################################################################## ##############################################################################
import sys, os, glob, distutils.file_util import sys, os, glob, distutils.file_util
DOCS_PATH="../../docs/latex/wx" DOCS_PATH="../../docs/latex/wx"
# Calls the given callback with the name of a documented class, its .tex related file, # Calls the given callback with the name of a documented class, its .tex related file,
# the content of that .tex file and the number of the line of the relative \class tag, # the content of that .tex file and the number of the line of the relative \class tag,
# for all documented class in DOCS_PATH. If the callback returns false the processing is stopped. # for all documented class in DOCS_PATH. If the callback returns false the processing is stopped.
# Returns the number of .tex files processed. # Returns the number of .tex files processed.
def scanTexFiles(callback): def scanTexFiles(callback):
count = 0 count = 0
for f in glob.glob(DOCS_PATH + '/*.tex'): for f in glob.glob(DOCS_PATH + '/*.tex'):
file = open(f, "r") file = open(f, "r")
if not file: if not file:
print "could not open %s" % f print "could not open %s" % f
continue continue
print "opened file %s" % f print "opened file %s" % f
count = count + 1 count = count + 1
# search \class tags # search \class tags
content = file.readlines() content = file.readlines()
classdecl = 0 classdecl = 0
for i in range(len(content)): for i in range(len(content)):
line = content[i] line = content[i]
if "\class{" in line: if "\class{" in line:
classdecl = classdecl + 1 classdecl = classdecl + 1
# polish the class name # polish the class name
classname = line classname = line
classname = classname[classname.find("\class{"):] classname = classname[classname.find("\class{"):]
classname = classname[classname.find("{")+1:classname.find("}")] classname = classname[classname.find("{")+1:classname.find("}")]
print " the class declared is named '%s'" % classname print " the class declared is named '%s'" % classname
# process this \class # process this \class
if not callback(classname, f, content, i): if not callback(classname, f, content, i):
return count return count
print " file %s contains %d class declarations" % (f, classdecl) print " file %s contains %d class declarations" % (f, classdecl)
return count return count