forked from AllenWLynch/lisa
-
Notifications
You must be signed in to change notification settings - Fork 8
/
make_docs.py
62 lines (41 loc) · 1.59 KB
/
make_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import lisa
from lisa import FromRegions, FromGenes, FromCoverage
import argparse
from lisa.cli.cli import oneshot_parser, multi_parser, regions_parser, coverage_parser
import argparse
import os
from argparse import HelpFormatter
from lisa.cli.cli import RstFormatter
from lisa.core.utils import Log
def new_format_help(self):
formatter = RstFormatter(prog = self.prog)
# description
formatter.add_text(self.description)
# usage
formatter.add_usage(self.usage, self._actions,
self._mutually_exclusive_groups)
# positionals, optionals and user-defined groups
for action_group in self._action_groups:
formatter.start_section(action_group.title)
formatter.add_text(action_group.description)
formatter.add_arguments(action_group._group_actions)
formatter.end_section()
# epilog
formatter.add_text(self.epilog)
# determine help from format above
return formatter.format_help()
def make_cli_page(parsers):
docs = lisa.cli.cli.__doc__
docs += '\n\n'.join([new_format_help(m) for m in parsers]).replace('make_docs.py', 'lisa')
return docs
def make_api_page(modules):
docs = lisa.__doc__
docs += '\n\n'.join([m.get_docs() for m in modules])
return docs
if __name__ == "__main__":
api_docs = make_api_page([FromGenes, FromRegions, FromCoverage])
with open('python_api.rst', 'w') as f:
print(api_docs, file = f)
cli_docs = make_cli_page([oneshot_parser, multi_parser, regions_parser, coverage_parser])
with open('cli.rst', 'w') as f:
print(cli_docs, file = f)