-
Notifications
You must be signed in to change notification settings - Fork 195
/
build_doc.py
66 lines (56 loc) · 1.59 KB
/
build_doc.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
63
64
65
66
#!/usr/bin/env python
# -*- coding: utf-8 -*
# Copyright: [CUP] - See LICENSE for details.
# Authors: Guannan Ma (@mythmgn),
"""
:description:
decorators related module
"""
import os
import sys
import argparse
_NOW_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
_TOP_PATH = os.path.abspath(_NOW_PATH + '/../')
# sys.path.insert(0, _NOW_PATH)
sys.path.insert(0, _TOP_PATH)
from cup import version
from cup.shell import oper
class DocGenerator(object):
"""
doc generator for cup
"""
def __init__(self, opts):
"""
doc generator by invoking sphinx
"""
self._kv_opts = opts
def build_rst(self, github=True):
"""build rst for cup"""
exclude = ''
if github:
exclude = ' cup/thirdp cup/bidu '
else:
exclude = ' cup/thirdp'
cmd = 'sphinx-apidoc {0}'
for key in self._kv_opts:
cmd = '{0} {1} {2}'.format(cmd, key, self._kv_opts[key])
print(cmd)
shell = oper.ShellExec()
shell.run(cmd, timeout=600)
if __name__ == '__main__':
kvs = {
'-F': ' ',
'-o': '{0}/cup'.format(_NOW_PATH),
'--doc-version': version.VERSION,
'--doc-author': version.AUTHOR,
'--ext-todo': ' ',
'--module-first': ' ',
}
gen = DocGenerator(kvs)
gen.build_rst()
helpinfo = "generate cup html docs"
parser = argparse.ArgumentParser(description=helpinfo)
helpinfo = "conf file of sphinx"
parser.add_argument('-c', '--conf', type=str, help=helpinfo)
parser.parse_args()
# vi:set tw=0 ts=4 sw=4 nowrap fdm=indent