]> git.saurik.com Git - wxWidgets.git/commitdiff
added the script used to add libraries to the documentation files (see patch 1756715)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 28 Jul 2007 12:14:30 +0000 (12:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 28 Jul 2007 12:14:30 +0000 (12:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47776 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

misc/scripts/update_doc_libs.py [new file with mode: 0644]

diff --git a/misc/scripts/update_doc_libs.py b/misc/scripts/update_doc_libs.py
new file mode 100644 (file)
index 0000000..3a57056
--- /dev/null
@@ -0,0 +1,109 @@
+##############################################################################\r
+# Name:       misc/scripts/update_doc_libs.py\r
+# Purpose:    Automatically insert \Library{} headers 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
+import sys, os, glob, distutils.file_util\r
+\r
+tofix = set()\r
+count = 0\r
+for f in glob.glob('*.tex'):\r
+    file = open(f, "r")\r
+    if not file:\r
+        print "could not open %s" % f\r
+        continue\r
+    print "opened file %s" % f\r
+    count = count + 1\r
+    \r
+    # search \class\r
+    content = file.readlines()\r
+    classdecl = 0\r
+    for i in range(len(content)):\r
+        line = content[i]\r
+        if "\class{" in line:\r
+            classdecl = classdecl + 1\r
+            \r
+            classname = line\r
+            classname = classname[classname.find("\class{"):]\r
+            classname = classname[classname.find("{")+1:classname.find("}")]\r
+            print " the class declared is named '%s'" % classname\r
+            \r
+            tofix.add(f)     # consider this .tex broken\r
+            \r
+            # now search the include file for this class\r
+            include = ""\r
+            for j in range(i,len(content)):\r
+                line = content[j]\r
+                if "wx/" in line and ".h" in line:\r
+                    include = line[line.find("wx/"):line.find(".h")+2]\r
+                    break\r
+            if include == "":\r
+                print " no include file declared for class %s" % classname\r
+                continue\r
+            \r
+            include = include.replace("\\_", "_")\r
+            print " the include file for %s is %s" % (classname, include)\r
+            \r
+            # now try to understand which libs contains this class\r
+            include = "../../../include/" + include\r
+            header = open(include, "r")\r
+            if not file:\r
+                print " could not open %s" % include\r
+                continue\r
+\r
+            decl = ""\r
+            content2 = header.readlines()\r
+            \r
+            # if they exist append port-specific headers contents\r
+            for c in ["wx/gtk/", "wx/msw/", "wx/mac/", "wx/generic/"]:\r
+                try:\r
+                    temp = include.replace("wx/", c)\r
+                    print " trying to open %s..." % temp\r
+                    header = open(temp, "r")\r
+                    headercontents = header.readlines()\r
+                    content2 = content2 + headercontents\r
+                    print " added %d lines from %s" % (len(headercontents), temp)\r
+                except:\r
+                    pass\r
+            \r
+            for line in content2:\r
+                if "class " in line and classname in line:\r
+                    if line.find("class") < line.find(classname):  # could be a comment\r
+                        if "_" in line:\r
+                            decl = line[line.find("_")+1:]\r
+                            decl = decl[:decl.find(" ")]\r
+                            decl = decl.replace("FWD_", "")\r
+                            decl = decl[0:1].upper() + decl[1:].lower()\r
+                            break\r
+                        elif " WXDLLEXPORT " in line:\r
+                            decl = "Core"\r
+                            break\r
+                        \r
+            if decl == "":\r
+                print " no declaration associated with %s" % classname\r
+                continue\r
+            \r
+            print " the declaration associated with %s is %s" % (classname, decl)\r
+            tofix.remove(f) # was a valid .tex (at least for current class)\r
+            \r
+            # now modify the .tex file\r
+            content.insert(j+2, "\wxheading{Library}\n\n\helpref{wx%s}{librarieslist}\n\n" % decl)\r
+            \r
+            # write it\r
+            file = open(f, "w")\r
+            file.write(''.join(content))\r
+            file.flush()\r
+            \r
+            file = open(f, "r")\r
+\r
+            print " updated %s" % f\r
+\r
+            \r
+    print " file %s contains %d class declarations" % (f, classdecl)\r
+\r
+print "\nProcessed %d files." % count\r
+print "There are %d files to fix:\n%s" % (len(tofix), '\n'.join(tofix))\r