1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
jsteemann 2015-12-09 00:22:43 +01:00
commit 928afcae6b
6 changed files with 67 additions and 82 deletions

View File

@ -137,7 +137,7 @@ build-book:
echo cp $${WD}/$${pic} $${pic}; \ echo cp $${WD}/$${pic} $${pic}; \
cp $${WD}/$${pic} $${pic}; \ cp $${WD}/$${pic} $${pic}; \
done done
python generateMdFiles.py $(NAME) ppbooks/ ../../js/apps/system/_admin/aardvark/APP/api-docs.json $(FILTER) python ../Scripts/generateMdFiles.py $(NAME) ppbooks/ ../../js/apps/system/_admin/aardvark/APP/api-docs.json $(FILTER)
cd ppbooks/$(NAME) && sed -i -e 's/VERSION_NUMBER/v$(newVersionNumber)/g' styles/header.js cd ppbooks/$(NAME) && sed -i -e 's/VERSION_NUMBER/v$(newVersionNumber)/g' styles/header.js
cd ppbooks/$(NAME) && sed -i -e 's/VERSION_NUMBER/v$(newVersionNumber)/g' README.md cd ppbooks/$(NAME) && sed -i -e 's/VERSION_NUMBER/v$(newVersionNumber)/g' README.md
@ -154,7 +154,7 @@ build-book:
cd ppbooks/$(NAME) && gitbook install cd ppbooks/$(NAME) && gitbook install
cd ppbooks/$(NAME) && gitbook build ./ ./../../books/$(NAME) cd ppbooks/$(NAME) && gitbook build ./ ./../../books/$(NAME)
python deprecated.py python ../Scripts/deprecated.py
make book-check-markdown-leftovers make book-check-markdown-leftovers
@ -183,8 +183,6 @@ check-docublocks:
grep -v ppbook |\ grep -v ppbook |\
grep -v allComments.txt |\ grep -v allComments.txt |\
grep -v Makefile |\ grep -v Makefile |\
grep -v codeBlockReader.py |\
grep -v generateMdFiles.py |\
grep -v '.*~:.*' |\ grep -v '.*~:.*' |\
grep -v '.*#.*:.*' \ grep -v '.*#.*:.*' \
> /tmp/rawindoc.txt > /tmp/rawindoc.txt
@ -192,8 +190,6 @@ check-docublocks:
grep -v ppbook |\ grep -v ppbook |\
grep -v allComments.txt |\ grep -v allComments.txt |\
grep -v Makefile |\ grep -v Makefile |\
grep -v codeBlockReader.py |\
grep -v generateMdFiles.py |\
grep -v '.*~:.*' |\ grep -v '.*~:.*' |\
grep -v '.*#.*:.*' \ grep -v '.*#.*:.*' \
>> /tmp/rawindoc.txt >> /tmp/rawindoc.txt
@ -204,8 +200,6 @@ check-docublocks:
grep -v ppbook |\ grep -v ppbook |\
grep -v allComments.txt |\ grep -v allComments.txt |\
grep -v Makefile |\ grep -v Makefile |\
grep -v codeBlockReader.py |\
grep -v generateMdFiles.py |\
grep -v '.*~:.*' |\ grep -v '.*~:.*' |\
grep -v '.*#.*:.*' \ grep -v '.*#.*:.*' \
>> /tmp/rawinprog.txt >> /tmp/rawinprog.txt
@ -248,7 +242,7 @@ clean: clean-intermediate
build-books-keep-md: build-books-keep-md:
@test -d books || mkdir books @test -d books || mkdir books
python codeBlockReader.py python ../Scripts/codeBlockReader.py
make build-book NAME=Users make build-book NAME=Users
build-books: clean-intermediate build-books-keep-md check-docublocks build-books: clean-intermediate build-books-keep-md check-docublocks

View File

@ -43,6 +43,16 @@ def getReference(name, source, verb):
raise Exception("invalid reference: " + ref + " in " + fn) raise Exception("invalid reference: " + ref + " in " + fn)
return ref 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): def unwrapPostJson(reference, layer):
global swagger global swagger
rc = '' rc = ''
@ -54,35 +64,29 @@ def unwrapPostJson(reference, layer):
if '$ref' in thisParam: if '$ref' in thisParam:
subStructRef = getReference(thisParam, reference, None) subStructRef = getReference(thisParam, reference, None)
rc += "<li><strong>" + param + "</strong>: " rc += ' ' * layer + " - **" + param + "**:\n"
rc += swagger['definitions'][subStructRef]['description'] + "<ul class=\"swagger-list\">"
rc += unwrapPostJson(subStructRef, layer + 1) rc += unwrapPostJson(subStructRef, layer + 1)
rc += "</li></ul>"
elif thisParam['type'] == 'object': elif thisParam['type'] == 'object':
rc += ' ' * layer + "<li><strong>" + param + "</strong>: " + brTrim(thisParam['description']) + "</li>" rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(brTrim(thisParam['description']), layer) + "\n"
elif swagger['definitions'][reference]['properties'][param]['type'] == 'array': elif swagger['definitions'][reference]['properties'][param]['type'] == 'array':
rc += ' ' * layer + "<li><strong>" + param + "</strong>: " + brTrim(thisParam['description']) rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(brTrim(thisParam['description']), layer)
if 'type' in thisParam['items']: if 'type' in thisParam['items']:
rc += " of type " + thisParam['items']['type']# rc += " of type " + thisParam['items']['type'] + "\n"
else: else:
if len(thisParam['items']) == 0: if len(thisParam['items']) == 0:
rc += "anonymous json object" rc += "anonymous json object\n"
else: else:
try: try:
subStructRef = getReference(thisParam['items'], reference, None) subStructRef = getReference(thisParam['items'], reference, None)
except: except:
print >>sys.stderr, "while analyzing: " + param print >>sys.stderr, "while analyzing: " + param
print >>sys.stderr, thisParam print >>sys.stderr, thisParam
rc += "\n<ul class=\"swagger-list\">" rc += "\n" + unwrapPostJson(subStructRef, layer + 1)
rc += unwrapPostJson(subStructRef, layer + 1)
rc += "</ul>"
rc += '</li>'
else: else:
rc += ' ' * layer + "<li><strong>" + param + "</strong>: " + thisParam['description'] + '</li>' rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(thisParam['description'], layer) + '\n'
return rc return rc
def getRestBodyParam(): def getRestBodyParam():
rc = "\n**Body Parameters**\n" rc = "\n**Body Parameters**\n"
addText = '' addText = ''
@ -93,13 +97,13 @@ def getRestBodyParam():
if 'additionalProperties' in thisVerb['parameters'][nParam]['schema']: if 'additionalProperties' in thisVerb['parameters'][nParam]['schema']:
addText = "free style json body" addText = "free style json body"
else: else:
addText = "<ul class=\"swagger-list\">" + unwrapPostJson( addText = unwrapPostJson(
getReference(thisVerb['parameters'][nParam]['schema'], route, verb),0) + "</ul>" getReference(thisVerb['parameters'][nParam]['schema'], route, verb),0)
rc += addText rc += addText
return rc return rc
def getRestReplyBodyParam(param): def getRestReplyBodyParam(param):
rc = "\n**Reply Body**\n<ul>" rc = "\n**Reply Body**\n"
try: try:
rc += unwrapPostJson(getReference(thisVerb['responses'][param]['schema'], route, verb), 0) rc += unwrapPostJson(getReference(thisVerb['responses'][param]['schema'], route, verb), 0)
@ -107,7 +111,7 @@ def getRestReplyBodyParam(param):
print >>sys.stderr,"failed to search " + param + " in: " print >>sys.stderr,"failed to search " + param + " in: "
print >>sys.stderr,json.dumps(thisVerb, indent=4, separators=(', ',': '), sort_keys=True) print >>sys.stderr,json.dumps(thisVerb, indent=4, separators=(', ',': '), sort_keys=True)
raise raise
return rc + "</ul>\n" return rc + "\n"
SIMPL_REPL_DICT = { SIMPL_REPL_DICT = {

View File

@ -289,10 +289,10 @@ def Typography(txt):
txt = txt[0:-1] txt = txt[0:-1]
# txt = BackTicks(txt) # txt = BackTicks(txt)
txt = AsteriskBold(txt) # txt = AsteriskBold(txt)
txt = AsteriskItalic(txt) # txt = AsteriskItalic(txt)
# txt = FN(txt) # txt = FN(txt)
txt = LIT(txt) # txt = LIT(txt)
# txt = FA(txt) # txt = FA(txt)
# #
# no way to find out the correct link for Swagger, # no way to find out the correct link for Swagger,
@ -487,32 +487,8 @@ def generic_handler_desc(cargo, r, message, op, para, name):
continue continue
line = Typography(line) line = Typography(line)
para[name] += line + '\n'
if r.DESCRIPTION_LI.match(line):
line = "<li>" + line[2:]
inLI = True
elif inLI and r.DESCRIPTION_SP.match(line):
line = line[2:]
elif inLI and r.DESCRIPTION_BL.match(line):
line = ""
else:
inLI = False
if not inUL and inLI:
line = " <ul class=\"swagger-list\">" + line
inUL = True
elif inUL and r.EMPTY_LINE.match(line):
line = "</ul> " + line
inUL = False
elif inLI and r.EMPTY_LINE.match(line):
line = "</li> " + line
inUL = False
if not inLI and r.EMPTY_LINE.match(line):
line = "<br>"
para[name] += line + ' '
para[name] = removeTrailingBR.sub("", para[name]) para[name] = removeTrailingBR.sub("", para[name])
def start_docublock(cargo, r=Regexen()): def start_docublock(cargo, r=Regexen()):
@ -675,7 +651,7 @@ def restbodyparam(cargo, r=Regexen()):
if restBodyParam == None: if restBodyParam == None:
# https://github.com/swagger-api/swagger-ui/issues/1430 # https://github.com/swagger-api/swagger-ui/issues/1430
# once this is solved we can skip this: # once this is solved we can skip this:
operation['description'] += "**A json post document with these Properties is required:**" operation['description'] += "**A json post document with these Properties is required:**\n"
restBodyParam = { restBodyParam = {
'name': 'Json Post Body', 'name': 'Json Post Body',
'x-description-offset': len(swagger['paths'][httpPath][method]['description']), 'x-description-offset': len(swagger['paths'][httpPath][method]['description']),
@ -913,7 +889,7 @@ def restreplybody(cargo, r=Regexen()):
if restReplyBodyParam == None: if restReplyBodyParam == None:
# https://github.com/swagger-api/swagger-ui/issues/1430 # https://github.com/swagger-api/swagger-ui/issues/1430
# once this is solved we can skip this: # once this is solved we can skip this:
operation['description'] += "**A json document with these Properties is returned:**" operation['description'] += "**A json document with these Properties is returned:**\n"
swagger['paths'][httpPath][method]['responses'][currentReturnCode][ swagger['paths'][httpPath][method]['responses'][currentReturnCode][
'x-description-offset'] = len(swagger['paths'][httpPath][method]['description']) 'x-description-offset'] = len(swagger['paths'][httpPath][method]['description'])
swagger['paths'][httpPath][method]['responses'][currentReturnCode]['schema'] = { swagger['paths'][httpPath][method]['responses'][currentReturnCode]['schema'] = {
@ -1169,6 +1145,16 @@ def getReference(name, source, verb):
raise Exception("invalid reference: " + ref + " in " + fn) raise Exception("invalid reference: " + ref + " in " + fn)
return ref 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): def unwrapPostJson(reference, layer):
global swagger global swagger
rc = '' rc = ''
@ -1180,32 +1166,27 @@ def unwrapPostJson(reference, layer):
if '$ref' in thisParam: if '$ref' in thisParam:
subStructRef = getReference(thisParam, reference, None) subStructRef = getReference(thisParam, reference, None)
rc += "<li><strong>" + param + "</strong>: " rc += ' ' * layer + " - **" + param + "**:\n"
rc += swagger['definitions'][subStructRef]['description'] + "<ul class=\"swagger-list\">"
rc += unwrapPostJson(subStructRef, layer + 1) rc += unwrapPostJson(subStructRef, layer + 1)
rc += "</li></ul>"
elif thisParam['type'] == 'object': elif thisParam['type'] == 'object':
rc += ' ' * layer + "<li><strong>" + param + "</strong>: " + brTrim(thisParam['description']) + "</li>" rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(brTrim(thisParam['description']), layer) + "\n"
elif swagger['definitions'][reference]['properties'][param]['type'] == 'array': elif swagger['definitions'][reference]['properties'][param]['type'] == 'array':
rc += ' ' * layer + "<li><strong>" + param + "</strong>: " + brTrim(thisParam['description']) rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(brTrim(thisParam['description']), layer)
if 'type' in thisParam['items']: if 'type' in thisParam['items']:
rc += " of type " + thisParam['items']['type']# rc += " of type " + thisParam['items']['type'] + "\n"
else: else:
if len(thisParam['items']) == 0: if len(thisParam['items']) == 0:
rc += "anonymous json object" rc += "anonymous json object\n"
else: else:
try: try:
subStructRef = getReference(thisParam['items'], reference, None) subStructRef = getReference(thisParam['items'], reference, None)
except: except:
print >>sys.stderr, "while analyzing: " + param print >>sys.stderr, "while analyzing: " + param
print >>sys.stderr, thisParam print >>sys.stderr, thisParam
rc += "\n<ul class=\"swagger-list\">" rc += "\n" + unwrapPostJson(subStructRef, layer + 1)
rc += unwrapPostJson(subStructRef, layer + 1)
rc += "</ul>"
rc += '</li>'
else: else:
rc += ' ' * layer + "<li><strong>" + param + "</strong>: " + thisParam['description'] + '</li>' rc += ' ' * layer + " - **" + param + "**: " + TrimThisParam(thisParam['description'], layer) + '\n'
return rc return rc
@ -1299,12 +1280,14 @@ for route in swagger['paths'].keys():
if thisVerb['parameters'][nParam]['in'] == 'body': if thisVerb['parameters'][nParam]['in'] == 'body':
descOffset = thisVerb['parameters'][nParam]['x-description-offset'] descOffset = thisVerb['parameters'][nParam]['x-description-offset']
addText = '' addText = ''
postText = thisVerb['description'][:descOffset] postText = ''
paramDesc = thisVerb['description'][:descOffset]
if len(paramDesc) > 0:
postText += paramDesc
if 'additionalProperties' in thisVerb['parameters'][nParam]['schema']: if 'additionalProperties' in thisVerb['parameters'][nParam]['schema']:
addText = "free style json body" addText = "\nfree style json body\n\n"
else: else:
addText = "<ul class=\"swagger-list\">" + unwrapPostJson( addText = "\n" + unwrapPostJson(getReference(thisVerb['parameters'][nParam]['schema'], route, verb),1) + "\n\n"
getReference(thisVerb['parameters'][nParam]['schema'], route, verb),0) + "</ul>"
postText += addText postText += addText
postText += thisVerb['description'][descOffset:] postText += thisVerb['description'][descOffset:]
@ -1315,30 +1298,34 @@ for route in swagger['paths'].keys():
if 'responses' in thisVerb: if 'responses' in thisVerb:
for nRC in thisVerb['responses']: for nRC in thisVerb['responses']:
if 'x-description-offset' in thisVerb['responses'][nRC]: if 'x-description-offset' in thisVerb['responses'][nRC]:
descOffset = thisVerb['responses'][nRC]['x-description-offset'] descOffset = thisVerb['responses'][nRC]['x-description-offset']
#print descOffset #print descOffset
#print offsetPlus #print offsetPlus
descOffset += offsetPlus descOffset += offsetPlus
addText = '' addText = '\n##HTTP ' + nRC
#print thisVerb['responses'][nRC]['description'] #print thisVerb['responses'][nRC]['description']
postText = thisVerb['description'][:descOffset] postText = thisVerb['description'][:descOffset]
#print postText #print postText
replyDescription = TrimThisParam(thisVerb['responses'][nRC]['description'], 0)
if (len(replyDescription) > 0):
addText += '\n' + replyDescription + '\n'
if 'additionalProperties' in thisVerb['responses'][nRC]['schema']: if 'additionalProperties' in thisVerb['responses'][nRC]['schema']:
addText = "free style json body" addText += "\n free style json body\n"
else: else:
addText = "<ul class=\"swagger-list\">" + unwrapPostJson( addText += "\n" + unwrapPostJson(
getReference(thisVerb['responses'][nRC]['schema'], route, verb),0) + "</ul>" getReference(thisVerb['responses'][nRC]['schema'], route, verb),0) + '\n'
#print addText #print addText
postText += addText postText += addText
postText += thisVerb['responses'][nRC]['description'][descOffset:] postText += thisVerb['description'][descOffset:]
offsetPlus += len(addText) offsetPlus += len(addText)
thisVerb['description'] = postText thisVerb['description'] = postText
#print '-'*80
#print thisVerb['description']
# Append the examples to the description: # Append the examples to the description:
if 'x-examples' in thisVerb and len(thisVerb['x-examples']) > 0: if 'x-examples' in thisVerb and len(thisVerb['x-examples']) > 0:
thisVerb['description'] += '<br>' thisVerb['description'] += '\n'
for nExample in range(0, len(thisVerb['x-examples'])): for nExample in range(0, len(thisVerb['x-examples'])):
thisVerb['description'] += thisVerb['x-examples'][nExample] thisVerb['description'] += thisVerb['x-examples'][nExample]
thisVerb['x-examples'] = []# todo unset! thisVerb['x-examples'] = []# todo unset!

View File

@ -515,7 +515,7 @@ triagens::basics::Json RestCursorHandler::buildExtra (triagens::aql::QueryResult
/// error occurs during query processing, the server will respond with *HTTP 400*. /// error occurs during query processing, the server will respond with *HTTP 400*.
/// Again, the body of the response will contain details about the error. /// Again, the body of the response will contain details about the error.
/// ///
/// A list of query errors can be found (../ArangoErrors/README.md) here. /// A [list of query errors can be found here](../ErrorCodes/README.md).
/// ///
/// ///
/// @RESTRETURNCODE{404} /// @RESTRETURNCODE{404}