Add tools to automatically extract documentation

This commit is contained in:
Grégory Soutadé
2014-12-19 11:35:00 +01:00
parent a35d462cb7
commit a37b661c1f
2 changed files with 45 additions and 0 deletions

29
tools/extract_doc.py Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env python
import sys
filename = sys.argv[1]
if filename.endswith('__init__.py'):
sys.exit(0)
package_name = filename.replace('/', '.').replace('.py', '')
sys.stdout.write('**%s**' % (package_name))
sys.stdout.write('\n\n')
# sys.stdout.write('-' * len(package_name))
# sys.stdout.write('\n\n')
sys.stderr.write('\tExtract doc from %s\n' % (filename))
with open(filename) as infile:
copy = False
for line in infile:
if line.strip() in ['"""', "'''"]:
if not copy:
copy = True
else:
break
elif copy:
sys.stdout.write(line)
sys.stdout.write('\n\n')