diff --git a/wxPython/wxPython/py/wxd/genapi.py b/wxPython/wxPython/py/wxd/genapi.py new file mode 100644 index 0000000000..f3cd4532d0 --- /dev/null +++ b/wxPython/wxPython/py/wxd/genapi.py @@ -0,0 +1,103 @@ +"""API generator for decorator classes. +""" + +__author__ = "Patrick K. O'Brien " +__cvsid__ = "$Id$" +__revision__ = "$Revision$"[11:-2] + + +import inspect + + +header = '''\ +"""Decorator classes for documentation and shell scripting.""" + +__author__ = "Patrick K. O'Brien " + + +# This file is automatically generated, and these are not the real +# wxPython classes. These are Python versions for documentation +# purposes only. + + +from wxPython.py.wxd import Parameters as wx + +try: + True +except NameError: + True = 1==1 + False = 1==0 +''' + + +modlist = [ + 'Base', + 'Window', + 'Frames', + 'Accelerators', + 'App', + 'ClipDragDrop', + 'Config', + 'Controls', + 'DataStructures', + 'DateTime', + 'Dialogs', + 'Drawing', + 'Errors', + 'EventFunctions', + 'Events', + 'FileSystem', + 'Functions', + 'Help', + 'ImageHandlers', + 'Joystick', + 'LayoutConstraints', + 'Logging', + 'Menus', + 'MimeTypes', + 'Misc', + 'Panel', + 'Printing', + 'Process', + 'SashSplitter', + 'Sizers', + 'Streams', + 'Threading', + 'ToolBar', + 'Tree', + 'Validators', + ] + + +def main(): + modules = {} + f = file('api/wx/__init__.py', 'w') + f.write(header) + for modname in modlist: + modules[modname] = __import__(modname, globals()) + for modname in modlist: + module = modules[modname] + try: + source = inspect.getsource(module) + except IOError: + print 'No source for', module + else: + # Remove everything up to the first class or function definition. + splitter = '\n\nclass ' + parts = source.split(splitter, 1) + if len(parts) == 2: + source = splitter + parts[1] + else: + splitter = '\n\ndef ' + parts = source.split(splitter, 1) + if len(parts) == 2: + source = splitter + parts[1] + source = '\n\n\n' + source.strip() + f.write(source) + print 'Writing', modname, 'to file...' + f.write('\n') + f.close() + + +if __name__ == '__main__': + main()