iwla

iwla Git Source Tree

Root/tools/extract_doc.py

Source at commit 4e02325733e5e8e4f5de2f0046e721f8da7abfff created 6 years 10 months ago.
By Gregory Soutade, Initial commit
1#!/usr/bin/env python
2
3import sys
4
5filename = sys.argv[1]
6
7if filename.endswith('__init__.py'):
8 sys.exit(0)
9
10package_name = filename.replace('/', '.').replace('.py', '')
11sys.stdout.write('%s' % (package_name))
12sys.stdout.write('\n')
13# sys.stdout.write('\n\n')
14sys.stdout.write('-' * len(package_name))
15sys.stdout.write('\n\n')
16
17sys.stderr.write('\tExtract doc from %s\n' % (filename))
18
19with open(filename) as infile:
20 copy = False
21 for line in infile:
22 if line.strip() in ['"""', "'''"]:
23 if not copy:
24 copy = True
25 else:
26 break
27 elif copy:
28 sys.stdout.write(' %s' % (line))
29
30sys.stdout.write('\n\n')

Archive Download this file

Branches

Tags