1 #~ This program is free software; you can redistribute it and/or modify
2 #~ it under the terms of the GNU General Public License as published by
3 #~ the Free Software Foundation; version 2 of the License.
5 #~ This program is distributed in the hope that it will be useful,
6 #~ but WITHOUT ANY WARRANTY; without even the implied warranty of
7 #~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 #~ GNU General Public License for more details.
10 # This script must run from a logic brick so it has access to the game engine api
11 # it assumes the root blender source directory is the current working directory
13 # Currently it only prints missing modules and methods (not attributes)
17 BGE_API_DOC_PATH = 'source/gameengine/PyDoc'
20 mods = ['GameLogic', 'Rasterizer', 'GameKeys']
23 mods_dict[m] = sys.modules[m]
29 for type_name in dir(GameTypes):
30 if type_name.startswith('__'):
33 type_object = getattr(GameTypes, type_name)
36 type_members[type_object.__name__] = members
38 for member in type_object.__dict__.keys():
39 if member.startswith('__'):
42 # print type_object.__name__ + '.' + k
43 members.append(member)
47 doc_dir= os.path.join(os.getcwd(), BGE_API_DOC_PATH)
49 if doc_dir not in sys.path:
50 sys.path.append(doc_dir)
53 def check_attribute(type_mame, member):
54 filename = os.path.join(doc_dir, type_mame + '.py')
57 file = open(filename, 'rU')
69 if l.startswith('@ivar') or l.startswith('@var'):
70 var = l.split()[1].split(':')[0]
84 print '\n\n\nChecking Docs'
88 for type_name in sorted(type_members.keys()):
89 members = type_members[type_name]
92 mod = __import__(type_name)
94 print "type: %s" % type_name
96 print "missing: %s - %s" % (type_name, str(sorted(members)))
99 reload(mod) # incase were editing it
102 type_class = getattr(mod, type_name)
104 print "missing class: %s.%s - %s" % (type_name, type_name, str(sorted(members)))
107 for member in sorted(members):
109 getattr(type_class, member)
111 print "\tfound: %s.%s" % (type_name, member)
113 if check_attribute(type_name, member):
115 print "\tfound attr: %s.%s" % (type_name, member)
117 print "\tmissing: %s.%s" % (type_name, member)
120 # Now check the modules
121 for mod_name, pymod in mods_dict.iteritems():
123 del sys.modules[mod_name]
125 # Now well get the python version
126 pydoc = __import__(mod_name)
127 pydoc = reload(pydoc) # avoid using the out dated pyc file only
130 for member in sorted(dir(pymod)):
131 if hasattr(pydoc, member) or check_attribute(mod_name, member):
133 print "\tfound module attr: %s.%s" % (mod_name, member)
135 print "\tmissing module attr: %s.%s" % (mod_name, member)
137 # Restore real module
138 sys.modules[mod_name] = pymod
141 sys.path.pop() # remove the pydoc dir from our import paths