[#19232] (2.5) Correction of cmake for windows about audio (jack and openal)
[blender.git] / source / gameengine / PyDoc / bge_api_validate_py.txt
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.
4
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.
9
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
12
13 # Currently it only prints missing modules and methods (not attributes)
14
15 import sys, os
16
17 BGE_API_DOC_PATH = 'source/gameengine/PyDoc'
18
19
20 mods = ['GameLogic', 'Rasterizer', 'GameKeys']
21 mods_dict = {}
22 for m in mods:
23         mods_dict[m] = sys.modules[m]
24
25
26 import GameTypes
27 type_members = {}
28
29 for type_name in dir(GameTypes):
30         if type_name.startswith('__'):
31                 continue
32         
33         type_object = getattr(GameTypes, type_name)
34         
35         members = []
36         type_members[type_object.__name__] = members
37         
38         for member in type_object.__dict__.keys():
39                 if member.startswith('__'):
40                         continue
41                 
42                 # print type_object.__name__ + '.' + k
43                 members.append(member)
44
45
46
47 doc_dir= os.path.join(os.getcwd(), BGE_API_DOC_PATH)
48
49 if doc_dir not in sys.path:
50         sys.path.append(doc_dir)
51
52
53 def check_attribute(class_ob, member):
54         doc = class_ob.__doc__
55         if not doc:
56                 return False
57         
58         for l in doc.split('\n'):
59                 l = l.strip()
60                 
61                 '''
62                         @ivar foo: blah blah
63                 to
64                         foo
65                         
66                 '''
67                 
68                 if l.startswith('@ivar') or l.startswith('@var'):
69                         var = l.split()[1].split(':')[0]
70                         
71                         if var == member:
72                                 return True
73         
74         return False
75         
76         
77         
78         
79
80
81 print '\n\n\nChecking Docs'
82
83 PRINT_OK = False
84
85 pymod = sys.modules['GameTypes']
86 del sys.modules['GameTypes'] # temp remove
87 mod = __import__('GameTypes') # get the python module
88 reload(mod) # incase were editing it
89 sys.modules['GameTypes'] = pymod
90
91 for type_name in sorted(type_members.keys()):
92         members = type_members[type_name]
93         
94         try:
95                 type_class = getattr(mod, type_name)
96         except:
97                 print "missing class: %s.%s - %s" % (type_name, type_name, str(sorted(members)))
98                 continue
99         
100         for member in sorted(members):
101                 try:
102                         getattr(type_class, member)
103                         if PRINT_OK:
104                                 print "\tfound: %s.%s" % (type_name, member)
105                 except:
106                         if check_attribute(type_class, member):
107                                 if PRINT_OK:
108                                         print "\tfound attr: %s.%s" % (type_name, member)
109                         else:
110                                 print "\tmissing: %s.%s" % (type_name, member)
111
112
113 # Now check the modules
114 for mod_name, pymod in mods_dict.iteritems():
115         print pymod
116         del sys.modules[mod_name]
117                 
118         # Now well get the python version
119         pydoc = __import__(mod_name)
120         pydoc = reload(pydoc) # avoid using the out dated pyc file only
121         print pydoc.__file__
122         
123         for member in sorted(dir(pymod)):
124                 if hasattr(pydoc, member) or check_attribute(pydoc, member):
125                         if PRINT_OK:
126                                 print "\tfound module attr: %s.%s" % (mod_name, member)
127                 else:
128                         print "\tmissing module attr: %s.%s" % (mod_name, member)
129         
130         # Restore real module
131         sys.modules[mod_name] = pymod
132
133
134 sys.path.pop() # remove the pydoc dir from our import paths
135
136