2009-04-06 13:27:28 +00:00
|
|
|
#~ This program is free software; you can redistribute it and/or modify
|
|
|
|
#~ it under the terms of the GNU General Public License as published by
|
|
|
|
#~ the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
#~ This program is distributed in the hope that it will be useful,
|
|
|
|
#~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
#~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
#~ GNU General Public License for more details.
|
|
|
|
|
|
|
|
# This script must run from a logic brick so it has access to the game engine api
|
|
|
|
# it assumes the root blender source directory is the current working directory
|
|
|
|
#
|
|
|
|
# Currently it only prints missing modules and methods (not attributes)
|
|
|
|
|
2009-04-24 20:27:04 +00:00
|
|
|
import sys, os
|
2009-04-06 13:27:28 +00:00
|
|
|
|
|
|
|
BGE_API_DOC_PATH = 'source/gameengine/PyDoc'
|
|
|
|
|
2009-04-24 20:27:04 +00:00
|
|
|
|
|
|
|
mods = ['GameLogic', 'Rasterizer', 'GameKeys']
|
|
|
|
mods_dict = {}
|
|
|
|
for m in mods:
|
|
|
|
mods_dict[m] = sys.modules[m]
|
|
|
|
|
|
|
|
|
2009-04-07 11:45:48 +00:00
|
|
|
import GameTypes
|
2009-04-06 13:27:28 +00:00
|
|
|
type_members = {}
|
|
|
|
|
|
|
|
for type_name in dir(GameTypes):
|
|
|
|
if type_name.startswith('__'):
|
|
|
|
continue
|
|
|
|
|
|
|
|
type_object = getattr(GameTypes, type_name)
|
|
|
|
|
|
|
|
members = []
|
|
|
|
type_members[type_object.__name__] = members
|
|
|
|
|
|
|
|
for member in type_object.__dict__.keys():
|
|
|
|
if member.startswith('__'):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# print type_object.__name__ + '.' + k
|
|
|
|
members.append(member)
|
|
|
|
|
2009-04-24 20:27:04 +00:00
|
|
|
|
2009-04-06 13:27:28 +00:00
|
|
|
|
|
|
|
doc_dir= os.path.join(os.getcwd(), BGE_API_DOC_PATH)
|
|
|
|
|
|
|
|
if doc_dir not in sys.path:
|
|
|
|
sys.path.append(doc_dir)
|
|
|
|
|
2009-04-07 11:45:48 +00:00
|
|
|
|
2009-05-14 10:59:38 +00:00
|
|
|
def check_attribute(class_ob, member):
|
2009-05-15 03:26:53 +00:00
|
|
|
doc = class_ob.__doc__
|
|
|
|
if not doc:
|
|
|
|
return False
|
|
|
|
|
|
|
|
for l in doc.split('\n'):
|
2009-04-07 11:45:48 +00:00
|
|
|
l = l.strip()
|
|
|
|
|
|
|
|
'''
|
|
|
|
@ivar foo: blah blah
|
|
|
|
to
|
|
|
|
foo
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
2009-04-24 20:27:04 +00:00
|
|
|
if l.startswith('@ivar') or l.startswith('@var'):
|
2009-04-07 11:45:48 +00:00
|
|
|
var = l.split()[1].split(':')[0]
|
|
|
|
|
|
|
|
if var == member:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '\n\n\nChecking Docs'
|
|
|
|
|
|
|
|
PRINT_OK = False
|
|
|
|
|
2009-05-14 10:59:38 +00:00
|
|
|
pymod = sys.modules['GameTypes']
|
|
|
|
del sys.modules['GameTypes'] # temp remove
|
|
|
|
mod = __import__('GameTypes') # get the python module
|
|
|
|
reload(mod) # incase were editing it
|
|
|
|
sys.modules['GameTypes'] = pymod
|
|
|
|
|
2009-04-06 13:27:28 +00:00
|
|
|
for type_name in sorted(type_members.keys()):
|
|
|
|
members = type_members[type_name]
|
|
|
|
|
|
|
|
try:
|
|
|
|
type_class = getattr(mod, type_name)
|
|
|
|
except:
|
2009-04-07 17:54:56 +00:00
|
|
|
print "missing class: %s.%s - %s" % (type_name, type_name, str(sorted(members)))
|
2009-04-06 13:27:28 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
for member in sorted(members):
|
|
|
|
try:
|
|
|
|
getattr(type_class, member)
|
2009-04-07 11:45:48 +00:00
|
|
|
if PRINT_OK:
|
|
|
|
print "\tfound: %s.%s" % (type_name, member)
|
2009-04-06 13:27:28 +00:00
|
|
|
except:
|
2009-05-14 10:59:38 +00:00
|
|
|
if check_attribute(type_class, member):
|
2009-04-07 11:45:48 +00:00
|
|
|
if PRINT_OK:
|
|
|
|
print "\tfound attr: %s.%s" % (type_name, member)
|
|
|
|
else:
|
|
|
|
print "\tmissing: %s.%s" % (type_name, member)
|
|
|
|
|
2009-04-24 20:27:04 +00:00
|
|
|
|
|
|
|
# Now check the modules
|
|
|
|
for mod_name, pymod in mods_dict.iteritems():
|
|
|
|
print pymod
|
|
|
|
del sys.modules[mod_name]
|
|
|
|
|
|
|
|
# Now well get the python version
|
|
|
|
pydoc = __import__(mod_name)
|
|
|
|
pydoc = reload(pydoc) # avoid using the out dated pyc file only
|
|
|
|
print pydoc.__file__
|
|
|
|
|
|
|
|
for member in sorted(dir(pymod)):
|
2009-05-14 10:59:38 +00:00
|
|
|
if hasattr(pydoc, member) or check_attribute(pydoc, member):
|
2009-04-24 20:27:04 +00:00
|
|
|
if PRINT_OK:
|
|
|
|
print "\tfound module attr: %s.%s" % (mod_name, member)
|
|
|
|
else:
|
|
|
|
print "\tmissing module attr: %s.%s" % (mod_name, member)
|
|
|
|
|
|
|
|
# Restore real module
|
|
|
|
sys.modules[mod_name] = pymod
|
|
|
|
|
|
|
|
|
|
|
|
sys.path.pop() # remove the pydoc dir from our import paths
|
|
|
|
|
|
|
|
|