Example: ' + exampleHeader.strip('\n ') + '
'
for line in examplefile.readlines():
operation['x-examples'][currentExample] += line
operation['x-examples'][currentExample] += '
\n'
line = ""
while not r.END_EXAMPLE_ARANGOSH_RUN.match(line):
line = fp.readline()
if not line:
return eof, (fp, line)
currentExample += 1
return examples, (fp, line)
################################################################################
### @brief eof
################################################################################
def eof(cargo):
global DEBUG, C_FILE
if DEBUG: print >> sys.stderr, "eof"
################################################################################
### @brief error
################################################################################
def error(cargo):
global DEBUG, C_FILE
if DEBUG: print >> sys.stderr, "error"
sys.stderr.write('Unidentifiable line:\n' + cargo)
################################################################################
### @brief comment
################################################################################
def comment(cargo, r=Regexen()):
global DEBUG, C_FILE
if DEBUG: print >> sys.stderr, "comment"
(fp, last) = cargo
while 1:
line = fp.readline()
if not line: return eof, (fp, line)
if r.FILE.match(line): C_FILE = True
next, c = next_step(fp, line, r)
if next:
return next, c
################################################################################
### @brief skip_code
###
### skip all non comment lines
################################################################################
def skip_code(cargo, r=Regexen()):
global DEBUG, C_FILE
if DEBUG: print >> sys.stderr, "skip_code"
(fp, last) = cargo
if not C_FILE:
return comment((fp, last), r)
while 1:
line = fp.readline()
if not line:
return eof, (fp, line)
if not r.NON_COMMENT.match(line):
return comment((fp, line), r)
################################################################################
### @brief main
################################################################################
automat = StateMachine()
automat.add_state(comment)
automat.add_state(eof, end_state=1)
automat.add_state(error, end_state=1)
automat.add_state(start_docublock)
automat.add_state(example_arangosh_run)
automat.add_state(examples)
automat.add_state(skip_code)
automat.add_state(restbodyparam)
automat.add_state(reststruct)
automat.add_state(restallbodyparam)
automat.add_state(restdescription)
automat.add_state(restheader)
automat.add_state(restheaderparam)
automat.add_state(restheaderparameters)
automat.add_state(restqueryparam)
automat.add_state(restqueryparameters)
automat.add_state(restreturncode)
automat.add_state(restreturncodes)
automat.add_state(restreplybody)
automat.add_state(resturlparam)
automat.add_state(resturlparameters)
def getOneApi(infile, filename):
automat.set_start(skip_code)
automat.set_fn(filename)
automat.run((infile, ''))
def getReference(name, source, verb):
try:
ref = name['$ref'][defLen:]
except Exception as x:
print >>sys.stderr, "No reference in: "
print >>sys.stderr, name
raise
if not ref in swagger['definitions']:
fn = ''
if verb:
fn = swagger['paths'][route][verb]['x-filename']
else:
fn = swagger['definitions'][source]['x-filename']
print >> sys.stderr, json.dumps(swagger['definitions'], indent=4, separators=(', ',': '), sort_keys=True)
raise Exception("invalid reference: " + ref + " in " + fn)
return ref
removeDoubleLF = re.compile("\n\n")
removeLF = re.compile("\n")
def TrimThisParam(text, indent):
text = text.rstrip('\n').lstrip('\n')
text = removeDoubleLF.sub("\n", text)
if (indent > 0):
indent = (indent + 2) # align the text right of the list...
return removeLF.sub("\n" + ' ' * indent, text)
def unwrapPostJson(reference, layer):
global swagger
rc = ''
for param in swagger['definitions'][reference]['properties'].keys():
thisParam = swagger['definitions'][reference]['properties'][param]
required = ('required' in swagger['definitions'][reference] and
param in swagger['definitions'][reference]['required'])
if '$ref' in thisParam:
subStructRef = getReference(thisParam, reference, None)
rc += ' ' * layer + " - **" + param + "**:\n"
rc += unwrapPostJson(subStructRef, layer + 1)
elif thisParam['type'] == 'object':
rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(brTrim(thisParam['description']), layer) + "\n"
elif swagger['definitions'][reference]['properties'][param]['type'] == 'array':
rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(brTrim(thisParam['description']), layer)
if 'type' in thisParam['items']:
rc += " of type " + thisParam['items']['type'] + "\n"
else:
if len(thisParam['items']) == 0:
rc += "anonymous json object\n"
else:
try:
subStructRef = getReference(thisParam['items'], reference, None)
except:
print >>sys.stderr, "while analyzing: " + param
print >>sys.stderr, thisParam
rc += "\n" + unwrapPostJson(subStructRef, layer + 1)
else:
rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(thisParam['description'], layer) + '\n'
return rc
files = {
"Administration" : ["js/actions/_admin/app.js",
"js/actions/_admin/routing/app.js",
"js/actions/_admin/server/app.js",
"js/actions/_admin/database/app.js",
"arangod/RestHandler/RestShutdownHandler.cpp",
"arangod/RestHandler/RestAdminLogHandler.cpp",
"js/actions/api-tasks.js",
"js/actions/api-endpoint.js",
"arangod/RestHandler/RestVersionHandler.cpp",
"js/actions/api-system.js" ],# TODO: no docu here.
"AQL" : [ "arangod/RestHandler/RestQueryHandler.cpp",
"js/actions/api-aqlfunction.js",
"js/actions/api-explain.js",
"arangod/RestHandler/RestQueryCacheHandler.cpp"],
"Bulk" : [ "arangod/RestHandler/RestExportHandler.cpp",
"arangod/RestHandler/RestImportHandler.cpp",
"arangod/RestHandler/RestBatchHandler.cpp" ],
"Collections" : [ "js/actions/_api/collection/app.js" ],
"Cursors" : [ "arangod/RestHandler/RestCursorHandler.cpp" ],
"Database" : [ "js/actions/api-database.js" ],
"Cluster" : ["js/actions/api-cluster.js"],
"Documents" : [ "arangod/RestHandler/RestDocumentHandler.cpp" ],
"Graph" : ["js/apps/system/_api/gharial/APP/gharial.js"],
"Graph edges" : [ "arangod/RestHandler/RestEdgeHandler.cpp", "arangod/RestHandler/RestEdgesHandler.cpp" ],
"Graph Traversal" : [ "js/actions/api-traversal.js" ],
"Indexes" : [ "js/actions/api-index.js" ],
"job" : [ "arangod/HttpServer/AsyncJobManager.cpp",
"arangod/RestHandler/RestJobHandler.cpp"],
"Replication" : [ "arangod/RestHandler/RestReplicationHandler.cpp" ],
"Simple Queries" : [ "js/actions/api-simple.js",
"arangod/RestHandler/RestSimpleHandler.cpp",
"arangod/RestHandler/RestSimpleQueryHandler.cpp" ],
"Transactions" : [ "js/actions/api-transaction.js" ],
"User handling" : [ "js/actions/_api/user/app.js" ],
"wal" : [ "js/actions/_admin/wal/app.js" ]
}
# Intentionaly not there:
# "structure" : [ "js/actions/api-structure.js" ],
if len(sys.argv) < 3:
print >> sys.stderr, "usage: " + sys.argv[0] + "