]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/gen_iface.py
Add docstrings for wxSTC methods
[wxWidgets.git] / src / stc / gen_iface.py
index f35fb2931bb823c7a1ef9250077258b5d1d092d0..67df43a35859a3326ff62e6f169ad1d78eeb5849 100644 (file)
@@ -21,6 +21,7 @@ H_TEMPLATE    = os.path.abspath('./stc.h.in')
 CPP_TEMPLATE  = os.path.abspath('./stc.cpp.in')
 H_DEST        = os.path.abspath('../../include/wx/stc/stc.h')
 CPP_DEST      = os.path.abspath('./stc.cpp')
+DOCSTR_DEST   = os.path.abspath('../../../wxPython/contrib/stc/_stc_gendocs.i')
 
 
 # Value prefixes to convert
@@ -582,7 +583,7 @@ methodOverrideMap = {
 
 #----------------------------------------------------------------------------
 
-def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest):
+def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest, docstr_dest):
     curDocStrings = []
     values = []
     methods = []
@@ -629,7 +630,7 @@ def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest):
     data = {}
     data['VALUES'] = processVals(values)
     data['CMDS']   = processVals(cmds)
-    defs, imps = processMethods(methods)
+    defs, imps, docstrings = processMethods(methods)
     data['METHOD_DEFS'] = defs
     data['METHOD_IMPS'] = imps
 
@@ -644,6 +645,7 @@ def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest):
     # write out destination files
     open(h_dest, 'w').write(h_text)
     open(cpp_dest, 'w').write(cpp_text)
+    open(docstr_dest, 'w').write(docstrings)
 
 
 
@@ -664,6 +666,7 @@ def processVals(values):
 def processMethods(methods):
     defs = []
     imps = []
+    dstr = []
 
     for retType, name, number, param1, param2, docs in methods:
         retType = retTypeMap.get(retType, retType)
@@ -674,6 +677,11 @@ def processMethods(methods):
         if name is None:
             continue
 
+        # Build docstrings
+        st = 'DocStr(wxStyledTextCtrl::%s,\n' \
+             '"%s", "");\n' % (name, '\n'.join(docs))
+        dstr.append(st)
+        
         # Build the method definition for the .h file
         if docs:
             defs.append('')
@@ -707,7 +715,7 @@ def processMethods(methods):
         imps.append(theImp)
 
 
-    return string.join(defs, '\n'), string.join(imps, '\n')
+    return '\n'.join(defs), '\n'.join(imps), '\n'.join(dstr)
 
 
 #----------------------------------------------------------------------------
@@ -827,7 +835,7 @@ def main(args):
     # TODO: parse command line args to replace default input/output files???
 
     # Now just do it
-    processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST)
+    processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST, DOCSTR_DEST)