2 A helper file to check which parts of the code have documentation and which are lacking documentation.
3 This because much of the Cura code is currently undocumented which needs to be improved.'
13 def treeWalk(moduleList, dirname, fnames):
14 dirname = dirname.replace("\\", ".").replace("/", ".")
15 if dirname == 'Cura.util.pymclevel':
17 if dirname == 'Cura.util.Power':
19 if dirname == 'Cura.plugins':
21 if dirname == 'Cura.resouces':
23 for moduleName in filter(lambda f: f.endswith('.py'), fnames):
24 moduleName = moduleName[:-3]
25 if moduleName == '__init__':
27 fullName = '%s.%s' % (dirname, moduleName)
29 module = __import__(fullName, fromlist=['Cura'], level=1)
30 moduleList.append(module)
32 #traceback.print_exc()
33 print "Failed to load: %s" % (fullName)
37 os.path.walk("Cura", treeWalk, moduleList)
44 for module in moduleList:
45 if inspect.getdoc(module):
48 undocList.append(module.__name__)
49 for name in dir(module):
50 a = getattr(module, name)
51 if type(a) is types.FunctionType:
56 # undocList.append('%s.%s' % (module.__name__, name))
57 elif type(a) is types.TypeType:
62 # undocList.append('%s.%s' % (module.__name__, name))
64 a2 = getattr(a, name2)
65 if type(a2) is types.MethodType:
66 if hasattr(a.__bases__[0], name2):
69 if inspect.getdoc(a2):
72 # undocList.append('%s.%s.%s' % (module.__name__, name, name2))
74 print '%d/%d modules have documentation.' % (moduleDocCount, len(moduleList))
75 print '%d/%d functions have documentation.' % (functionDocCount, functionCount)
76 print '%d/%d types have documentation.' % (typeDocCount, typeCount)
78 print 'You might want to document:'
79 for n in xrange(0, 10):
80 print random.Random().choice(undocList)
82 if __name__ == '__main__':