forked from yogurt-cultures/kefir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_docs.py
42 lines (35 loc) · 826 Bytes
/
print_docs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from inspect import getmembers, isfunction
import kefir
from kefir import phonology
from kefir import predication
from kefir import case
modules_to_document = [
kefir,
case,
phonology,
predication,
]
DOCSTRING_TOKEN = "'''"
def include_line(part):
return part.strip().startswith('#')
for module in modules_to_document:
module_name = module.__name__
content = open(module.__file__).read()
docs = [
part
for part in content.split(DOCSTRING_TOKEN)
if include_line(part)
]
if module_name == 'kefir':
print('<details open>')
else:
print('<details>')
print('<summary>%s</summary>' % module_name)
for doc in docs:
tab = ' '
for line in doc.splitlines():
if line.startswith(tab):
print(line.lstrip(tab))
else:
print(line)
print('</details>')