aboutsummaryrefslogtreecommitdiffstats
path: root/doc/generate-libbe-txt.py
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2010-06-20 19:19:06 -0400
committerChris Ball <cjb@laptop.org>2010-06-20 19:19:06 -0400
commit0df4bd7ae194bb07f36a2a69a0549037de01cb52 (patch)
treeea9128bbbedd8df9b1d6c737f704260874680a6b /doc/generate-libbe-txt.py
parent429e33fb4c7be8daa791fb744a14024ef27a72c2 (diff)
parenta2a51929a848ffa6db92ec7218994461ecccb50a (diff)
downloadbugseverywhere-0df4bd7ae194bb07f36a2a69a0549037de01cb52.tar.gz
Merge with Trevor.
Diffstat (limited to 'doc/generate-libbe-txt.py')
-rw-r--r--doc/generate-libbe-txt.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/doc/generate-libbe-txt.py b/doc/generate-libbe-txt.py
new file mode 100644
index 0000000..35eb5c4
--- /dev/null
+++ b/doc/generate-libbe-txt.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+#
+# Copyright
+
+"""Auto-generate reStructuredText of the libbe module tree for Sphinx.
+"""
+
+import sys
+import os, os.path
+
+sys.path.insert(0, os.path.abspath('..'))
+from test import python_tree
+
+def title(modname):
+ t = ':mod:`%s`' % modname
+ delim = '*'*len(t)
+ return '\n'.join([delim, t, delim, '', ''])
+
+def automodule(modname):
+ return '\n'.join([
+ '.. automodule:: %s' % modname,
+ ' :members:',
+ ' :undoc-members:',
+ '', ''])
+
+def toctree(children):
+ if len(children) == 0:
+ return ''
+ return '\n'.join([
+ '.. toctree::',
+ ' :maxdepth: 2',
+ '',
+ ] + [
+ ' %s.txt' % c for c in sorted(children)
+ ] + ['', ''])
+
+def make_module_txt(modname, children):
+ filename = os.path.join('libbe', '%s.txt' % modname)
+ if not os.path.exists('libbe'):
+ os.mkdir('libbe')
+ if os.path.exists(filename):
+ return None # don't overwrite potentially hand-written files.
+ f = file(filename, 'w')
+ f.write(title(modname))
+ f.write(automodule(modname))
+ f.write(toctree(children))
+ f.close()
+
+if __name__ == '__main__':
+ pt = python_tree(root_path='../libbe', root_modname='libbe')
+ for node in pt.traverse():
+ make_module_txt(node.modname, [c.modname for c in node])