]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/docs/bin/simplify.py
HandlePrintClient shouldn't go above a top-level window
[wxWidgets.git] / wxPython / docs / bin / simplify.py
index 4997cdcae10655d6174a6deb2ae6619b506c1651..4e58799509b41e143c8b9b59ade974546bc5752b 100755 (executable)
@@ -15,6 +15,11 @@ DEST="docs/xml/wxPython-metadata.xml"
 SRC="docs/xml-raw"
 
 
+classMap = {
+    'wxString'   : 'String',
+    'void'       : '',
+    }
+
 
 def getModuleNames():
     """
@@ -38,7 +43,14 @@ def getAttr(node, name):
         return None
 
 
-
+def fixType(typeStr):
+    """
+    Fixup type string, dropping the swig pointer and other flags
+    """
+    pos = typeStr.rfind('.')
+    if pos != -1:
+        typeStr = typeStr[pos+1:]
+    return classMap.get(typeStr, typeStr)
 
 
 def processModule(newDocNode, modulename):
@@ -54,7 +66,7 @@ def processModule(newDocNode, modulename):
 
     # make a module element
     name = getAttr(topNode, "module")
-    assert name == modulename # sanity check    
+    ##assert name == modulename # sanity check    
 
     moduleNode = libxml2.newNode("module")
     moduleNode.setProp("name", name)    
@@ -63,14 +75,14 @@ def processModule(newDocNode, modulename):
     node = topNode.children
     while node is not None:
         if node.name == "include":
-            processInclude(moduleNode, node, 0)
+            processInclude(moduleNode, node)
         node = node.next
 
     doc.freeDoc()
 
 
 
-def processInclude(moduleNode, includeNode, level):
+def processInclude(moduleNode, includeNode):
     """
     Almost everything we are interested in is inside an <include>,
     which may also be nested.
@@ -91,16 +103,16 @@ def processInclude(moduleNode, includeNode, level):
     node = includeNode.children
     while node is not None:
         if node.name == "insert":
-            processInsert(moduleNode, node, level)
+            processInsert(moduleNode, node)
 
         elif node.name == "class":
-            processClass(moduleNode, node, level)
+            processClass(moduleNode, node)
 
         elif node.name == "cdecl" and getAttr(node, "view") == "globalfunctionHandler":
             func = libxml2.newNode("method")
             func.setProp("name",    getAttr(node, "sym_name"))
             func.setProp("oldname", getAttr(node, "name"))
-            func.setProp("type",    getAttr(node, "type"))
+            func.setProp("type",    fixType(getAttr(node, "type")))
             doCheckOverloaded(func, node)
             doDocStrings(func, node)
             doParamList(func, node)
@@ -108,13 +120,13 @@ def processInclude(moduleNode, includeNode, level):
             
                           
         elif node.name == "include":
-            processInclude(moduleNode, node, level+1)
+            processInclude(moduleNode, node)
 
         node = node.next
 
 
 
-def processInsert(parentNode, insertNode, level):
+def processInsert(parentNode, insertNode):
     """
     Check for pythoncode
     """
@@ -126,14 +138,17 @@ def processInsert(parentNode, insertNode, level):
 
 
 
-def processClass(parentNode, classNode, level):
+def processClass(parentNode, classNode):
     """
     Handle classes, constructors, methods, etc.
     """
     # make class element
     klass = libxml2.newNode("class")
-    klass.setProp("name",    getAttr(classNode, "sym_name"))
-    klass.setProp("oldname", getAttr(classNode, "name"))
+    name = getAttr(classNode, "sym_name")
+    oldname = getAttr(classNode, "name")
+    classMap[oldname] = name
+    klass.setProp("name",    name)
+    klass.setProp("oldname", oldname)
     klass.setProp("module",  getAttr(classNode, "module"))
     doDocStrings(klass, classNode)
     parentNode.addChild(klass)
@@ -141,7 +156,8 @@ def processClass(parentNode, classNode, level):
     # check for baseclass(es)
     for node in classNode.xpathEval2("attributelist/baselist/base"):
         baseclass = libxml2.newNode("baseclass")
-        baseclass.setProp("name", node.prop("name"))
+        basename = node.prop("name")
+        baseclass.setProp("name", classMap.get(basename, basename))
         klass.addChild(baseclass)
 
     # check for constructors/destructors
@@ -162,7 +178,7 @@ def processClass(parentNode, classNode, level):
         if view == "memberfunctionHandler":
             func = libxml2.newNode("method")
             func.setProp("name", getAttr(node, "sym_name"))
-            func.setProp("type",    getAttr(node, "type"))
+            func.setProp("type", fixType(getAttr(node, "type")))
             doCheckOverloaded(func, node)
             doDocStrings(func, node)
             doParamList(func, node)
@@ -171,7 +187,7 @@ def processClass(parentNode, classNode, level):
         elif view == "staticmemberfunctionHandler":
             func = libxml2.newNode("staticmethod")
             func.setProp("name", getAttr(node, "sym_name"))
-            func.setProp("type",    getAttr(node, "type"))
+            func.setProp("type", fixType(getAttr(node, "type")))
             doCheckOverloaded(func, node)
             doDocStrings(func, node)
             doParamList(func, node)
@@ -180,7 +196,7 @@ def processClass(parentNode, classNode, level):
         elif view == "variableHandler":
             prop = libxml2.newNode("property")
             prop.setProp("name", getAttr(node, "sym_name"))
-            prop.setProp("type", getAttr(node, "type"))
+            prop.setProp("type", fixType(getAttr(node, "type")))
             if getAttr(node, "feature_immutable"):
                 prop.setProp("readonly", "yes")
             else:
@@ -199,8 +215,8 @@ def doParamList(parentNode, srcNode):
         plist = libxml2.newNode("paramlist")
         for p in params:
             pnode = libxml2.newNode("param")
-            pnode.setProp("name",    getAttr(p, "name"))
-            pnode.setProp("type",    getAttr(p, "type"))
+            pnode.setProp("name", getAttr(p, "name"))
+            pnode.setProp("type", fixType(getAttr(p, "type")))
             pnode.setProp("default", getAttr(p, "value"))
             plist.addChild(pnode)
         parentNode.addChild(plist)
@@ -230,13 +246,10 @@ def doDocStrings(parentNode, srcNode):
     
     autodoc = getAttr(srcNode, "python_autodoc")
     docstr  = getAttr(srcNode, "feature_docstring")
-    refdoc  = getAttr(srcNode, "feature_refdoc")
     if autodoc:
         parentNode.addChild(makeDocElement("autodoc", autodoc))
     if docstr:
         parentNode.addChild(makeDocElement("docstring", docstr))
-    if refdoc:
-        parentNode.addChild(makeDocElement("refdoc", refdoc))
         
 
 
@@ -255,7 +268,7 @@ def main():
         processModule(newTopNode, m)
 
     newDoc.saveFormatFile(DEST, True)
-
+    print "Wrote simplified metadata to", DEST
 
 #---------------------------------------------------------------------------