3 from os.path import join
4 from inspect import getsource, getmembers, isclass, isfunction, ismethod, ismodule
5 from importlib import import_module
11 from os.path import dirname, abspath, join, normpath
14 HERE = dirname(abspath(__file__))
15 PATH = normpath(join(HERE, '..', '..'))
16 if PATH not in sys.path:
17 sys.path.insert(1, PATH)
20 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
23 <title>{title}</title>
24 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
25 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8">
26 <meta http-equiv="content-style-type" content="text/css">
27 <meta http-equiv="expires" content="0">
37 def write_source(name, content):
38 fh = file(join(root, name)+'.html', 'w')
39 fh.write(format_html(name, content))
42 def format_html(title, content):
43 return htmltmpl.format(title=title, content=content)
45 def parse_module(module):
46 module = import_module(module)
47 write_source(module.__name__, getsource(module))
48 # classes = [(cls, value) for cls, value in getattr(module, '__dict__').items() if value == types.ClassType]
49 classes = getmembers(module, isclass)
50 for name, obj in classes:
51 write_source(module.__name__ + '.' + name, getsource(obj))
52 # methods = [(meth, value) for meth, value in getattr(obj, '__dict__').items() if type(value) == types.MethodType]
53 methods = getmembers(obj, ismethod)
54 for meth, value in methods:
55 write_source(module.__name__ + '.' + name + '.' + meth, getsource(value))
57 #functions = [(func, value) for func, value in getattr(module, '__dict__').items() if type(value) == types.FunctionType]
58 functions = getmembers(module, isfunction)
59 for name, obj in functions:
60 write_source(module.__name__ + '.' + name, getsource(obj))
62 def process_modules():
64 from os.path import abspath, dirname, normpath, splitext, basename
65 here = abspath(__file__)
66 directory = dirname(here)
67 pyfiles = glob(normpath(join(directory, '..', '*.py')))
69 pyf = splitext(basename(pyf))[0]
70 modname = 'tiramisu.' + pyf
71 if not '__init__' in modname:
74 pyfiles = glob(normpath(join(directory, '..', 'test', '*.py')))
76 pyf = splitext(basename(pyf))[0]
77 modname = 'tiramisu.test.' + pyf
78 if not '__init__' in modname: