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