5 """Auto-generate reStructuredText of the libbe module tree for Sphinx.
11 sys.path.insert(0, os.path.abspath('..'))
12 from test import python_tree
15 t = ':mod:`%s`' % modname
17 return '\n'.join([delim, t, delim, '', ''])
19 def automodule(modname):
21 '.. automodule:: %s' % modname,
26 def toctree(children):
27 if len(children) == 0:
34 ' %s.txt' % c for c in sorted(children)
37 def make_module_txt(modname, children, subdir='libbe'):
38 filename = os.path.join(subdir, '%s.txt' % modname)
39 if not os.path.exists(subdir):
41 if os.path.exists(filename):
42 return None # don't overwrite potentially hand-written files.
43 f = file(filename, 'w')
44 f.write(title(modname))
45 f.write(automodule(modname))
46 f.write(toctree(children))
49 if __name__ == '__main__':
50 pt = python_tree(root_path='../libbe', root_modname='libbe')
51 for node in pt.traverse():
52 make_module_txt(node.modname, [c.modname for c in node])