1
This commit is contained in:
parent
51af678d37
commit
37b18e9297
@ -8,4 +8,7 @@ import mydoc
|
||||
|
||||
workDir = os.getcwd()
|
||||
doc = mydoc.MyDoc(workDir)
|
||||
doc.convert()
|
||||
if len(sys.argv) > 1 and sys.argv[1] == '-g':
|
||||
doc.generate()
|
||||
else:
|
||||
doc.convert()
|
||||
|
@ -132,3 +132,27 @@ class MyDoc(object):
|
||||
[outRsp(p, 1) for p in item.fields]
|
||||
self._wf.write(' * }\n')
|
||||
self._wf.write(' */\n')
|
||||
|
||||
def generate(self):
|
||||
scheme = json.loads(open(self._workDir + 'apilist.json', 'r').read())
|
||||
for key, val in scheme['apis'].items():
|
||||
wf = open(self._workDir + key.replace('Controller', '') + '.py', 'w')
|
||||
wf.write('# -*- coding: utf-8 -*-\n\n')
|
||||
wf.write('import _common\n\n')
|
||||
wf.write('class %s(object):\n\n' % (key.replace('Controller', '')))
|
||||
wf.write(' def __init__(self):\n' % ())
|
||||
wf.write(' self.apis = [\n' % ())
|
||||
for api in val:
|
||||
wf.write(" {\n" % ())
|
||||
wf.write(" 'desc': '%s',\n" % (api))
|
||||
wf.write(" 'group': '%s',\n" % (key.replace('Controller', '')))
|
||||
wf.write(" 'url': 'webapp/index.php?c=%s&a=%s',\n" % (key.replace('Controller', ''), api))
|
||||
wf.write(" 'params': [\n" % ())
|
||||
wf.write(" _common.ReqHead(),\n" % ())
|
||||
wf.write(" ],\n" % ())
|
||||
wf.write(" 'response': [\n" % ())
|
||||
wf.write(" _common.RspHead(),\n" % ())
|
||||
wf.write(" ]\n" % ())
|
||||
wf.write(" },\n" % ())
|
||||
wf.write(' ]\n' % ())
|
||||
wf.close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user