mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of ssh://github.com/ArangoDB/ArangoDB into devel
This commit is contained in:
commit
746ab57f98
|
@ -1,26 +1,77 @@
|
|||
all: build-books
|
||||
|
||||
.PHONY: md-files
|
||||
.PHONY:
|
||||
|
||||
MDPP_FILES = $(wildcard Users/*.mdpp Users/*/*.mdpp Users/*/*/*.mdpp)
|
||||
MD_FILES = $(wildcard Users/*/*.md Users/*/*/*.md)
|
||||
newVersionNumber = $(shell cat ../../VERSION)
|
||||
|
||||
md-files:
|
||||
@for file in $(basename $(MDPP_FILES)); do echo "converting $${file}.mdpp"; markdown-pp.py $${file}.mdpp $${file}.md; done
|
||||
################################################################################
|
||||
# per book targets
|
||||
check-summary:
|
||||
@find . -name \*.md |grep -v books/ |sed -e "s;./$(NAME)/;;" |grep -vf SummaryBlacklist.txt |sort > /tmp/is_md.txt
|
||||
@cat $(NAME)/SUMMARY.md |sed -e "s;.*(;;" -e "s;).*;;" |sort |grep -v '# Summary' > /tmp/is_summary.txt
|
||||
@if test "`comm -3 /tmp/is_md.txt /tmp/is_summary.txt|wc -l`" -ne 0; then \
|
||||
echo "not all files are mapped to the summary!"; \
|
||||
echo " files found | files in summary"; \
|
||||
comm -3 /tmp/is_md.txt /tmp/is_summary.txt; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
clean-md-files:
|
||||
@for file in $(basename $(MD_FILES)); do rm -v $${file}.md; done
|
||||
rm -f `find -name \*.mdpp |sed "s;.mdpp;.md;"`
|
||||
book-check-leftover-docublocks:
|
||||
@if test "`grep -r \"@startDocuBlock\" --include \"*.html\" books/$(NAME) | wc -l`" -ne 0; then \
|
||||
echo ; \
|
||||
echo "@startDocuBlock markers still found in generated output files:"; \
|
||||
grep -rl "@startDocuBlock" --include "*.html" books/$(NAME) | sed -e "s/^/- /g"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
clean-books:
|
||||
@rm -rvf books
|
||||
book-check-markdown-leftovers:
|
||||
@if test "`find books/$(NAME) -name '*.html' -exec grep -- '##' {} \; -print | wc -l`" -gt 0; then \
|
||||
echo "found these unconverted markdown titles: "; \
|
||||
find books/$(NAME) -name '*.html' -exec grep '##' {} \; -print; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
build-book-symlinks:
|
||||
echo "generate backwards compatibility symlinks:"
|
||||
cd books/$(NAME); pwd; \
|
||||
find . -name "README.mdpp" |\
|
||||
sed -e 's:README\.mdpp$$::' |\
|
||||
awk '{print "ln -s index.html " $$1 "README.html"}' |\
|
||||
bash
|
||||
|
||||
build-book:
|
||||
test -d ppbooks/$(NAME) || mkdir -p ppbooks/$(NAME)
|
||||
cd ppbooks/$(NAME); test -l SUMMARY.md || ln -s ../../$(NAME)/SUMMARY.md .
|
||||
cd ppbooks/$(NAME); test -l book.json || ln -s ../../$(NAME)/book.json .
|
||||
cd ppbooks/$(NAME); test d styles || cp -a ../../$(NAME)/styles .
|
||||
cd ppbooks/$(NAME) && sed -ie 's/VERSION_NUMBER/$(newVersionNumber)/g' styles/header.js
|
||||
python generateMdFiles.py $(NAME) ppbooks/
|
||||
|
||||
test -d books/$(NAME) || mkdir -p books/$(NAME)
|
||||
|
||||
cd ppbooks/$(NAME) && gitbook install
|
||||
cd ppbooks/$(NAME) && gitbook build ./ ./../../books/$(NAME)
|
||||
python deprecated.py
|
||||
|
||||
make book-check-leftover-docublocks
|
||||
make book-check-markdown-leftovers
|
||||
|
||||
clean-book:
|
||||
@rm -rvf books/$(NAME) ppbooks/$(NAME)
|
||||
|
||||
clean-book-intermediate:
|
||||
@rm -rvf ppbooks/$(NAME)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Global targets
|
||||
|
||||
check-docublocks:
|
||||
grep -R '^@startDocuBlock' . |grep -v allComments.txt > /tmp/rawindoc.txt
|
||||
grep -R '@startDocuBlock' . |grep -v allComments.txt > /tmp/rawindoc.txt
|
||||
cat /tmp/rawindoc.txt | sed "s;.*ck ;;" |sort -u > /tmp/indoc.txt
|
||||
grep -R '^/// @startDocuBlock' ../../lib ../../arangod ../../arangosh ../../js |grep -v aardvark > /tmp/rawinprog.txt
|
||||
cat /tmp/rawinprog.txt |sed "s;.*ck ;;" |sort > /tmp/inprog_raw.txt
|
||||
grep -R '@startDocuBlockInline' >> /tmp/rawinprog.txt
|
||||
cat /tmp/rawinprog.txt |sed -e "s;.*ck ;;" -e "s;.*ne ;;" |sort > /tmp/inprog_raw.txt
|
||||
@cat /tmp/inprog_raw.txt |sort -u > /tmp/inprog.txt
|
||||
@if test "`cat /tmp/inprog.txt |wc -l`" -ne "`cat /tmp/inprog_raw.txt|wc -l`"; then \
|
||||
echo "Duplicate entry found in the source trees:"; \
|
||||
|
@ -46,56 +97,19 @@ check-docublocks:
|
|||
exit 1; \
|
||||
fi
|
||||
|
||||
check-summary:
|
||||
@find . -name \*.md |grep -v books/ |sed -e "s;./Users/;;" |grep -vf SummaryBlacklist.txt |sort > /tmp/is_md.txt
|
||||
@cat Users/SUMMARY.md |sed -e "s;.*(;;" -e "s;).*;;" |sort |grep -v '# Summary' > /tmp/is_summary.txt
|
||||
@if test "`comm -3 /tmp/is_md.txt /tmp/is_summary.txt|wc -l`" -ne 0; then \
|
||||
echo "not all files are mapped to the summary!"; \
|
||||
echo " files found | files in summary"; \
|
||||
comm -3 /tmp/is_md.txt /tmp/is_summary.txt; \
|
||||
exit 1; \
|
||||
fi
|
||||
clean-intermediate:
|
||||
make clean-book-intermediate NAME=Users
|
||||
|
||||
book-check-leftover-docublocks:
|
||||
@if test "`grep -r \"@startDocuBlock\" --include \"*.html\" books/$(NAME) | wc -l`" -ne 0; then \
|
||||
echo ; \
|
||||
echo "@startDocuBlock markers still found in generated output files:"; \
|
||||
grep -rl "@startDocuBlock" --include "*.html" books/$(NAME) | sed -e "s/^/- /g"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
book-check-markdown-leftovers:
|
||||
@if test "`find books/Users/ -name '*.html' -exec grep -- '##' {} \; -print | wc -l`" -gt 0; then \
|
||||
echo "found these unconverted markdown titles: "; \
|
||||
find books/Users/ -name '*.html' -exec grep '##' {} \; -print; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
clean: clean-md-files clean-books
|
||||
clean: clean-intermediate
|
||||
rm -f allComments.txt
|
||||
|
||||
|
||||
.PHONY: build-books
|
||||
|
||||
build-books: build-books-keep-md # not now: check-docublocks
|
||||
make clean-md-files
|
||||
echo "generate backwards compatibility symlinks:"
|
||||
cd books/Users; pwd; \
|
||||
find . -name "README.mdpp" |\
|
||||
sed -e 's:README\.mdpp$$::' |\
|
||||
awk '{print "ln -s index.html " $$1 "README.html"}' |\
|
||||
bash
|
||||
|
||||
build-books-keep-md: md-files check-summary
|
||||
build-books-keep-md:
|
||||
@test -d books || mkdir books
|
||||
make build-book NAME=Users
|
||||
make book-check-leftover-docublocks NAME=Users
|
||||
make book-check-markdown-leftovers NAME=Users
|
||||
|
||||
build-book:
|
||||
@test -d books/$(NAME) || mkdir books/$(NAME)
|
||||
python codeBlockReader.py
|
||||
python bot.py
|
||||
cd $(NAME) && gitbook install
|
||||
cd $(NAME) && gitbook build ./ ./../books/$(NAME)
|
||||
python deprecated.py
|
||||
cd books/$(NAME) && sed -ie 's/VERSION_NUMBER/$(newVersionNumber)/g' styles/header.js
|
||||
make build-book NAME=Users
|
||||
|
||||
build-books: clean-intermediate build-books-keep-md check-docublocks
|
||||
|
|
|
@ -35,12 +35,13 @@ advantage that you can use autocompletion.
|
|||
\__,_|_| \__,_|_| |_|\__, |\___/|___/_| |_|
|
||||
|___/
|
||||
|
||||
Welcome to arangosh 1.x.y. Copyright (c) 2012 triAGENS GmbH.
|
||||
Using Google V8 3.9.4 JavaScript engine.
|
||||
Welcome to arangosh 2.x.y. Copyright (c) 2012 triAGENS GmbH.
|
||||
Using Google V8 4.1.0.27 JavaScript engine.
|
||||
Using READLINE 6.1.
|
||||
|
||||
Connected to Arango DB 127.0.0.1:8529 Version 2.2.0
|
||||
|
||||
arangosh> help
|
||||
------------------------------------- Help -------------------------------------
|
||||
Predefined objects:
|
||||
arango: ArangoConnection
|
||||
|
@ -87,8 +88,12 @@ database. The database object is accessible via the variable *db*.
|
|||
Creating a collection is simple. You can use the *_create* method
|
||||
of the *db* variable.
|
||||
|
||||
arangosh> db._create("example");
|
||||
[ArangoCollection 70628, "example" (status loaded)]
|
||||
@startDocuBlockInline 01_workWithColl_create
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{01_workWithColl_create}
|
||||
~addIgnoreCollection("example")
|
||||
db._create("example");
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 01_workWithColl_create
|
||||
|
||||
After the collection has been created you can easily access it using
|
||||
the path *db.example*. The collection currently shows as *loaded*,
|
||||
|
@ -96,9 +101,12 @@ meaning that it's loaded into memory. If you restart the server and
|
|||
access the collection again it will now show as *unloaded*. You can
|
||||
also manually unload a collection.
|
||||
|
||||
arangosh> db.example.unload();
|
||||
arangosh> db.example;
|
||||
[ArangoCollection 70628, "example" (status unloaded)]
|
||||
@startDocuBlockInline 02_workWithColl_unload
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{02_workWithColl_unload}
|
||||
db.example.unload();
|
||||
db.example;
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 02_workWithColl_unload
|
||||
|
||||
Whenever you use a collection ArangoDB will automatically load it
|
||||
into memory for you.
|
||||
|
@ -106,106 +114,66 @@ into memory for you.
|
|||
In order to create new documents in a collection use the *save*
|
||||
operation.
|
||||
|
||||
arangosh> db.example.save({ Hello : "World" });
|
||||
{ "error" : false, "_id" : "example/1512420", "_key" : "1512420", "_rev" : "1512420" }
|
||||
arangosh> db.example.save({ "name" : "John Doe", "age" : 29 });
|
||||
{ "error" : false, "_id" : "example/1774564", _key : "1774564", "_rev" : "1774564" }
|
||||
arangosh> db.example.save({ "name" : "Jane Smith", "age" : 31 });
|
||||
{ "error" : false, "_id" : "example/1993214", "_key" : "1993214", "_rev" : "1993214" }
|
||||
@startDocuBlockInline 03_workWithColl_save
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{03_workWithColl_save}
|
||||
db.example.save({ Hello : "World" });
|
||||
db.example.save({ "name" : "John Doe", "age" : 29 });
|
||||
db.example.save({ "name" : "Jane Smith", "age" : 31 });
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 03_workWithColl_save
|
||||
|
||||
Just storing documents would be no fun. We now want to select some of
|
||||
the stored documents again. In order to select all elements of a
|
||||
collection, one can use the *toArray* method:
|
||||
|
||||
arangosh> db.example.toArray()
|
||||
[
|
||||
{
|
||||
"_id" : "example/1993214",
|
||||
"_key" : "1993214",
|
||||
"_rev" : "1993214",
|
||||
"age" : 31,
|
||||
"name" : "Jane Smith"
|
||||
},
|
||||
{
|
||||
"_id" : "example/1774564",
|
||||
"_key" : "1774564",
|
||||
"_rev" : "1774564",
|
||||
"age" : 29,
|
||||
"name" : "John Doe"
|
||||
},
|
||||
{
|
||||
"_id" : "example/1512420",
|
||||
"_key" : "1512420",
|
||||
"_rev" : "1512420",
|
||||
"Hello" : "World"
|
||||
}
|
||||
]
|
||||
|
||||
The last document was a mistake – so let's delete it:
|
||||
|
||||
arangosh> db.example.remove("example/1512420")
|
||||
true
|
||||
arangosh> db.example.toArray()
|
||||
[
|
||||
{
|
||||
"_id" : "example/1993214",
|
||||
"_key" : "1993214",
|
||||
"_rev" : "1993214",
|
||||
"age" : 31,
|
||||
"name" : "Jane Smith"
|
||||
},
|
||||
{
|
||||
"_id" : "example/1774564",
|
||||
"_key" : "1774564",
|
||||
"_rev" : "1774564",
|
||||
"age" : 29,
|
||||
"name" : "John Doe"
|
||||
}
|
||||
]
|
||||
@startDocuBlockInline 04_workWithColl_directAcess
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{04_workWithColl_directAcess}
|
||||
db.example.toArray()
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 04_workWithColl_directAcess
|
||||
|
||||
Now we want to look for a person with a given name. We can use
|
||||
*byExample* for this. The method returns an array of documents
|
||||
matching a given example.
|
||||
|
||||
arangosh> db.example.byExample({ name: "Jane Smith" }).toArray()
|
||||
[
|
||||
{
|
||||
"_id" : "example/1993214",
|
||||
"_key" : "1993214",
|
||||
"_rev" : "1993214",
|
||||
"age" : 31,
|
||||
"name" : "Jane Smith"
|
||||
}
|
||||
]
|
||||
@startDocuBlockInline 05_workWithColl_byExample
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{05_workWithColl_byExample}
|
||||
db.example.byExample({ name: "Jane Smith" }).toArray()
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 05_workWithColl_byExample
|
||||
|
||||
While the *byExample* works very well for simple queries where you
|
||||
combine the conditions with an `and`. The syntax above becomes messy for *joins*
|
||||
and *or* conditions. Therefore ArangoDB also supports a full-blown
|
||||
query language, AQL. To run an AQL query, use the *db._query* method:.
|
||||
|
||||
arangosh> db._query('FOR user IN example FILTER user.name == "Jane Smith" RETURN user').toArray()
|
||||
[
|
||||
{
|
||||
"_id" : "example/1993214",
|
||||
"_key" : "1993214",
|
||||
"_rev" : "1993214",
|
||||
"age" : 31,
|
||||
"name" : "Jane Smith"
|
||||
}
|
||||
]
|
||||
@startDocuBlockInline 05_workWithColl_AQL_STR
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{05_workWithColl_AQL_STR}
|
||||
db._query('FOR user IN example FILTER user.name == "Jane Smith" RETURN user').toArray()
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 05_workWithColl_AQL_STR
|
||||
|
||||
Searching for all persons with an age above 30:
|
||||
|
||||
arangosh> db._query('FOR user IN example FILTER user.age > 30 RETURN user').toArray()
|
||||
[
|
||||
{
|
||||
"_id" : "example/1993214",
|
||||
"_key" : "1993214",
|
||||
"_rev" : "1993214",
|
||||
"age" : 31,
|
||||
"name" : "Jane Smith"
|
||||
}
|
||||
]
|
||||
@startDocuBlockInline 06_workWithColl_AOQL_INT
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{06_workWithColl_AOQL_INT}
|
||||
db._query('FOR user IN example FILTER user.age > 30 RETURN user').toArray()
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 06_workWithColl_AOQL_INT
|
||||
|
||||
|
||||
John was put in there by mistake – so let's delete him again; We fetch
|
||||
the `_id` using *byExample*:
|
||||
|
||||
@startDocuBlockInline 07_workWithColl_remove
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{07_workWithColl_remove}
|
||||
db.example.remove(db.example.byExample({ name: "John Doe" }).toArray()[0]._id)
|
||||
db.example.toArray()
|
||||
~addIgnoreCollection("example")
|
||||
~db._drop("example")
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 07_workWithColl_remove
|
||||
|
||||
|
||||
You can learn all about the query language [Aql](../Aql/README.md). Note that
|
||||
*_query* is a short-cut for *_createStatement* and *execute*. We will
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
def walk_on_files(dirpath):
|
||||
for root, dirs, files in os.walk(dirpath):
|
||||
for file in files:
|
||||
if file.endswith(".md"):
|
||||
if file == "SUMMARY.md":
|
||||
pass
|
||||
elif file == "Index.md":
|
||||
pass
|
||||
else:
|
||||
full_path= os.path.join(root, file)
|
||||
f=open(full_path,"rU")
|
||||
textFile=f.read()
|
||||
f.close()
|
||||
findStartCode(textFile,full_path)
|
||||
replaceCode(full_path)
|
||||
return
|
||||
|
||||
def findStartCode(textFile,full_path):
|
||||
match = re.findall(r'@startDocuBlock\s*(\w+)', textFile)
|
||||
if match:
|
||||
for find in match:
|
||||
getTextFromSourceFile(find, full_path)
|
||||
matchInline = re.findall(r'@startDocuBlockInline\s*(\w+)', textFile)
|
||||
if matchInline:
|
||||
for find in matchInline:
|
||||
getTextFromSourceFileInline(find, full_path)
|
||||
|
||||
def getTextFromSourceFile(searchText, full_path):
|
||||
''' reads a single block from allComments.txt'''
|
||||
f=open("allComments.txt", 'rU')
|
||||
s=f.read()
|
||||
match = re.search(r'@startDocuBlock\s+'+ searchText + "(?:\s+|$)" +'(.+?)@endDocuBlock', s,re.DOTALL)
|
||||
if match:
|
||||
textExtracted = match.group(1)
|
||||
textExtracted = textExtracted.replace("<br />","\n")
|
||||
replaceText(textExtracted, full_path, searchText)
|
||||
|
||||
def getTextFromSourceFileInline(searchText, full_path):
|
||||
''' reads a single block from allComments.txt'''
|
||||
f=open("allComments.txt", 'rU')
|
||||
s=f.read()
|
||||
match = re.search(r'@startDocuBlockInline\s+'+ searchText + "(?:\s+|$)" +'(.+?)@endDocuBlock', s,re.DOTALL)
|
||||
if match:
|
||||
textExtracted = match.group(1)
|
||||
textExtracted = textExtracted.replace("<br />","\n")
|
||||
replaceTextInline(textExtracted, full_path, searchText)
|
||||
|
||||
def replaceText(text, pathOfFile, searchText):
|
||||
''' reads the mdpp and generates the md '''
|
||||
f=open(pathOfFile,"rU")
|
||||
if f:
|
||||
s=f.read()
|
||||
f.close()
|
||||
f=open(pathOfFile,'w')
|
||||
replaced = re.sub("@startDocuBlock\s+"+ searchText + "(?:\s+|$)",text,s)
|
||||
f.write(replaced)
|
||||
f.close()
|
||||
|
||||
def replaceTextInline(text, pathOfFile, searchText):
|
||||
''' reads the mdpp and generates the md '''
|
||||
f=open(pathOfFile,"rU")
|
||||
if f:
|
||||
s=f.read()
|
||||
f.close()
|
||||
f=open(pathOfFile,'w')
|
||||
replaced = re.sub(r' *@startDocuBlockInline\s+'+ searchText +'.*@endDocuBlock', text, s, flags=re.DOTALL)
|
||||
f.write(replaced)
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
def replaceCode(pathOfFile):
|
||||
f=open(pathOfFile,"rU")
|
||||
if f:
|
||||
s=f.read()
|
||||
f.close()
|
||||
f=open(pathOfFile,'w')
|
||||
lines = re.sub(r"<!--(\s*.+\s)-->","",s)
|
||||
#HTTP API changing code
|
||||
lines = re.sub(r"@brief(.+)",r"\g<1>", lines)
|
||||
lines = re.sub(r"@RESTHEADER{([\s\w\/\_{}-]*),([\s\w-]*)}", r"###\g<2>\n`\g<1>`", lines)
|
||||
lines = re.sub(r"@RESTDESCRIPTION","", lines)
|
||||
lines = re.sub(r"@RESTURLPARAM(\s+)","**URL Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTQUERYPARAM(\s+)","**Query Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTHEADERPARAM(\s+)","**Header Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTBODYPARAM(\s+)","**Body Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTRETURNCODES","**Return Codes**\n", lines)
|
||||
lines = re.sub(r"@RESTURLPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@PARAMS", "**Parameters**\n", lines)
|
||||
lines = re.sub(r"@PARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTHEADERPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTQUERYPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTBODYPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTPARAM{([\s\w\-]*),([\s\w\_\|-]*),\s[optional]}", r"* *\g<1>* (\g<3>):", lines)
|
||||
lines = re.sub(r"@RESTPARAM{([\s\w-]*),([\s\w\_\|-]*),\s*(\w+)}", r"* *\g<1>*:", lines)
|
||||
lines = re.sub(r"@RESTRETURNCODE{(.*)}", r"* *\g<1>*:", lines)
|
||||
lines = re.sub(r"@RESTBODYPARAMS{(.*)}", r"*(\g<1>)*", lines)
|
||||
lines = lines.replace("@EXAMPLES","**Examples**")
|
||||
lines = lines.replace("@RESTPARAMETERS","")
|
||||
lines = lines.replace("@RESTPARAMS","")
|
||||
# Error codes replace
|
||||
lines = re.sub(r"(####)#+", r"", lines)
|
||||
# lines = re.sub(r"- (\w+):\s*@LIT{(.+)}", r"\n*\g<1>* - **\g<2>**:", lines)
|
||||
lines = re.sub(r"(.+),(\d+),\"(.+)\",\"(.+)\"", r"\n*\g<2>* - **\g<3>**: \g<4>", lines)
|
||||
f.write(lines)
|
||||
f.close()
|
||||
|
||||
def replaceCodeIndex(pathOfFile):
|
||||
f=open(pathOfFile,"rU")
|
||||
if f:
|
||||
s=f.read()
|
||||
f.close()
|
||||
f=open(pathOfFile,'w')
|
||||
lines = re.sub(r"<!--(\s*.+\s)-->","",s)
|
||||
#HTTP API changing code
|
||||
lines = re.sub(r"@brief(.+)",r"\g<1>", lines)
|
||||
lines = re.sub(r"@RESTHEADER{([\s\w\/\_{}-]*),([\s\w-]*)}", r"###\g<2>\n`\g<1>`", lines)
|
||||
f.write(lines)
|
||||
f.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
path = ["Documentation/Books/Users"]
|
||||
for i in path:
|
||||
dirpath = os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.pardir,"ArangoDB/../../"+i))
|
||||
print "Replacing docublocks with content..."
|
||||
walk_on_files(dirpath)
|
|
@ -173,7 +173,6 @@ def fetch_comments(dirpath):
|
|||
if filename.endswith(validExtensions) and (filename.find("#") < 0):
|
||||
|
||||
filepath = os.path.join(root, filename)
|
||||
print "Searching for docublocks in " + filepath
|
||||
file_comments = file_content(filepath)
|
||||
for comment in file_comments:
|
||||
fh.write("\n<!-- filename: %s -->\n" % filename)
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
import sys
|
||||
import re
|
||||
import os
|
||||
import MarkdownPP
|
||||
|
||||
dokuBlocks = [{},{}]
|
||||
|
||||
def _mkdir_recursive(path):
|
||||
sub_path = os.path.dirname(path)
|
||||
if not os.path.exists(sub_path):
|
||||
_mkdir_recursive(sub_path)
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
|
||||
|
||||
def replaceCode(lines):
|
||||
lines = re.sub(r"<!--(\s*.+\s)-->","", lines)
|
||||
#HTTP API changing code
|
||||
lines = re.sub(r"@brief(.+)",r"\g<1>", lines)
|
||||
lines = re.sub(r"@RESTHEADER{([\s\w\/\_{}-]*),([\s\w-]*)}", r"###\g<2>\n`\g<1>`", lines)
|
||||
lines = re.sub(r"@RESTDESCRIPTION","", lines)
|
||||
lines = re.sub(r"@RESTURLPARAM(\s+)","**URL Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTQUERYPARAM(\s+)","**Query Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTHEADERPARAM(\s+)","**Header Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTBODYPARAM(\s+)","**Body Parameters**\n", lines)
|
||||
lines = re.sub(r"@RESTRETURNCODES","**Return Codes**\n", lines)
|
||||
lines = re.sub(r"@RESTURLPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@PARAMS", "**Parameters**\n", lines)
|
||||
lines = re.sub(r"@PARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTHEADERPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTQUERYPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTBODYPARAM", "@RESTPARAM", lines)
|
||||
lines = re.sub(r"@RESTPARAM{([\s\w\-]*),([\s\w\_\|-]*),\s[optional]}", r"* *\g<1>* (\g<3>):", lines)
|
||||
lines = re.sub(r"@RESTPARAM{([\s\w-]*),([\s\w\_\|-]*),\s*(\w+)}", r"* *\g<1>*:", lines)
|
||||
lines = re.sub(r"@RESTRETURNCODE{(.*)}", r"* *\g<1>*:", lines)
|
||||
lines = re.sub(r"@RESTBODYPARAMS{(.*)}", r"*(\g<1>)*", lines)
|
||||
lines = lines.replace("@EXAMPLES","**Examples**")
|
||||
lines = lines.replace("@RESTPARAMETERS","")
|
||||
lines = lines.replace("@RESTPARAMS","")
|
||||
# Error codes replace
|
||||
lines = re.sub(r"(####)#+", r"", lines)
|
||||
# lines = re.sub(r"- (\w+):\s*@LIT{(.+)}", r"\n*\g<1>* - **\g<2>**:", lines)
|
||||
lines = re.sub(r"(.+),(\d+),\"(.+)\",\"(.+)\"", r"\n*\g<2>* - **\g<3>**: \g<4>", lines)
|
||||
return lines
|
||||
|
||||
def replaceCodeIndex(lines):
|
||||
lines = re.sub(r"<!--(\s*.+\s)-->","", lines)
|
||||
#HTTP API changing code
|
||||
lines = re.sub(r"@brief(.+)",r"\g<1>", lines)
|
||||
lines = re.sub(r"@RESTHEADER{([\s\w\/\_{}-]*),([\s\w-]*)}", r"###\g<2>\n`\g<1>`", lines)
|
||||
return lines
|
||||
|
||||
################################################################################
|
||||
# main loop over all files
|
||||
################################################################################
|
||||
def walk_on_files(inDirPath, outDirPath):
|
||||
for root, dirs, files in os.walk(inDirPath):
|
||||
for file in files:
|
||||
if file.endswith(".mdpp"):
|
||||
inFileFull = os.path.join(root, file)
|
||||
outFileFull = os.path.join(outDirPath, re.sub(r'mdpp$', 'md', inFileFull));
|
||||
print "%s -> %s" % (inFileFull, outFileFull)
|
||||
_mkdir_recursive(os.path.join(outDirPath, root))
|
||||
mdpp = open(inFileFull, "r")
|
||||
md = open(outFileFull, "w")
|
||||
MarkdownPP.MarkdownPP(input=mdpp, output=md, modules=MarkdownPP.modules.keys())
|
||||
mdpp.close()
|
||||
md.close()
|
||||
findStartCode(md, outFileFull);
|
||||
|
||||
def findStartCode(fd,full_path):
|
||||
inFD = open(full_path, "r")
|
||||
textFile =inFD.read()
|
||||
inFD.close()
|
||||
#print "-" * 80
|
||||
#print textFile
|
||||
matchInline = re.findall(r'@startDocuBlockInline\s*(\w+)', textFile)
|
||||
if matchInline:
|
||||
for find in matchInline:
|
||||
#print "7"*80
|
||||
print full_path + " " + find
|
||||
textFile = replaceTextInline(textFile, full_path, find)
|
||||
#print textFile
|
||||
|
||||
match = re.findall(r'@startDocuBlock\s*(\w+)', textFile)
|
||||
if match:
|
||||
for find in match:
|
||||
#print "8"*80
|
||||
textFile = replaceText(textFile, full_path, find)
|
||||
#print textFile
|
||||
|
||||
textFile = replaceCodeIndex(textFile)
|
||||
textFile = replaceCode(textFile)
|
||||
#print "9" * 80
|
||||
#print textFile
|
||||
outFD = open(full_path, "w")
|
||||
|
||||
outFD.truncate()
|
||||
outFD.write(textFile)
|
||||
outFD.close()
|
||||
|
||||
|
||||
def replaceText(text, pathOfFile, searchText):
|
||||
''' reads the mdpp and generates the md '''
|
||||
global dokuBlocks
|
||||
if not searchText in dokuBlocks[0]:
|
||||
print "Failed to locate the docublock '%s' for replacing it into the file '%s'\n have:" % (searchText, pathOfFile)
|
||||
print dokuBlocks[0].keys()
|
||||
exit(1)
|
||||
rc= re.sub("@startDocuBlock\s+"+ searchText + "(?:\s+|$)", dokuBlocks[0][searchText], text)
|
||||
return rc
|
||||
|
||||
def replaceTextInline(text, pathOfFile, searchText):
|
||||
''' reads the mdpp and generates the md '''
|
||||
global dokuBlocks
|
||||
if not searchText in dokuBlocks[1]:
|
||||
print "Failed to locate the inline docublock '%s' for replacing it into the file '%s'\n have:" % (searchText, pathOfFile)
|
||||
print dokuBlocks[1].keys()
|
||||
exit(1)
|
||||
return re.sub(r' *@startDocuBlockInline\s+'+ searchText +'.*@endDocuBlock\s' + searchText, dokuBlocks[1][searchText], text, flags=re.DOTALL)
|
||||
|
||||
################################################################################
|
||||
# Read the docublocks into memory
|
||||
################################################################################
|
||||
thisBlock = ""
|
||||
thisBlockName = ""
|
||||
thisBlockType = 0
|
||||
|
||||
STATE_SEARCH_START = 0
|
||||
STATE_SEARCH_END = 1
|
||||
def readStartLine(line):
|
||||
global thisBlockName, thisBlockType, thisBlock, dokuBlocks
|
||||
if ("@startDocuBlock" in line):
|
||||
if "@startDocuBlockInline" in line:
|
||||
thisBlockType = 1
|
||||
else:
|
||||
thisBlockType = 0
|
||||
try:
|
||||
thisBlockName = re.search(r" *start[0-9a-zA-Z]*\s\s*([0-9a-zA-Z_ ]*)\s*$", line).group(1).strip()
|
||||
except:
|
||||
print "failed to read startDocuBlock: [" + line + "]"
|
||||
exit(1)
|
||||
dokuBlocks[thisBlockType][thisBlockName] = ""
|
||||
return STATE_SEARCH_END
|
||||
return STATE_SEARCH_START
|
||||
|
||||
def readNextLine(line):
|
||||
global thisBlockName, thisBlockType, thisBlock, dokuBlocks
|
||||
if '@endDocuBlock' in line:
|
||||
return STATE_SEARCH_START
|
||||
dokuBlocks[thisBlockType][thisBlockName] += line
|
||||
#print "reading " + thisBlockName
|
||||
#print dokuBlocks[thisBlockType][thisBlockName]
|
||||
return STATE_SEARCH_END
|
||||
|
||||
def loadDokuBlocks():
|
||||
state = STATE_SEARCH_START
|
||||
f=open("allComments.txt", 'rU')
|
||||
count = 0;
|
||||
for line in f.readlines():
|
||||
if state == STATE_SEARCH_START:
|
||||
state = readStartLine(line)
|
||||
elif state == STATE_SEARCH_END:
|
||||
state = readNextLine(line)
|
||||
|
||||
#if state == STATE_SEARCH_START:
|
||||
# print dokuBlocks[thisBlockType].keys()
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: input-directory output-directory")
|
||||
exit(1)
|
||||
|
||||
inDir = sys.argv[1]
|
||||
outDir = sys.argv[2]
|
||||
loadDokuBlocks()
|
||||
print "loaded %d / %d docu blocks" % (len(dokuBlocks[0]), len(dokuBlocks[1]))
|
||||
#print dokuBlocks[0].keys()
|
||||
walk_on_files(inDir, outDir)
|
|
@ -35,7 +35,7 @@
|
|||
### @author Copyright 2011-2014, triagens GmbH, Cologne, Germany
|
||||
################################################################################
|
||||
|
||||
import re, sys, string, os
|
||||
import re, sys, string, os, re
|
||||
from pprint import pprint
|
||||
|
||||
################################################################################
|
||||
|
@ -117,7 +117,7 @@ ArangoshSetup = ""
|
|||
### @brief filter to only output this one:
|
||||
################################################################################
|
||||
|
||||
FilterForTestcase = ""
|
||||
FilterForTestcase = None
|
||||
|
||||
################################################################################
|
||||
### @brief states
|
||||
|
@ -285,6 +285,20 @@ var checkForOrphanTestCollections = function(msg) {
|
|||
}
|
||||
};
|
||||
|
||||
var addIgnoreCollection = function(collectionName) {
|
||||
print("from now on ignoring this collection whether its dropped: " + collectionName);
|
||||
collectionAlreadyThere.push(collectionName);
|
||||
};
|
||||
|
||||
var removeIgnoreCollection = function(collectionName) {
|
||||
print("from now on checking again whether this collection dropped: " + collectionName);
|
||||
for (j=0; j < collectionAlreadyThere.length; j++) {
|
||||
if (collectionAlreadyThere[j] === collectionName) {
|
||||
collectionAlreadyThere[j] = undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Set the first available list of already there collections:
|
||||
var err = allErrors;
|
||||
checkForOrphanTestCollections('Collections already there which we will ignore from now on:');
|
||||
|
@ -312,7 +326,7 @@ def matchStartLine(line, filename):
|
|||
print >> sys.stderr, "%s\nduplicate test name '%s' in file %s!\n%s\n" % ('#' * 80, name, filename, '#' * 80)
|
||||
sys.exit(1)
|
||||
# if we match for filters, only output these!
|
||||
if ((len(FilterForTestcase) != 0) and (FilterForTestcase != name)):
|
||||
if ((FilterForTestcase != None) and not FilterForTestcase.match(name)):
|
||||
print >> sys.stderr, "filtering test case %s" %name
|
||||
return("", STATE_BEGIN);
|
||||
|
||||
|
@ -331,11 +345,11 @@ def matchStartLine(line, filename):
|
|||
sys.exit(1)
|
||||
|
||||
# if we match for filters, only output these!
|
||||
if ((len(FilterForTestcase) != 0) and (FilterForTestcase != name)):
|
||||
if ((FilterForTestcase != None) and not FilterForTestcase.match(name)):
|
||||
print >> sys.stderr, "filtering test case %s" %name
|
||||
return("", STATE_BEGIN);
|
||||
|
||||
ArangoshCases.append(name)
|
||||
ArangoshCases.append(name)
|
||||
ArangoshFiles[name] = True
|
||||
ArangoshRun[name] = ""
|
||||
return (name, STATE_ARANGOSH_RUN)
|
||||
|
@ -583,7 +597,9 @@ def loopDirectories():
|
|||
|
||||
elif fstate == OPTION_FILTER:
|
||||
fstate = OPTION_NORMAL
|
||||
FilterForTestcase = filename;
|
||||
if (len(filename) > 0):
|
||||
FilterForTestcase = re.compile(filename);
|
||||
print dir(FilterForTestcase)
|
||||
elif fstate == OPTION_ARANGOSH_SETUP:
|
||||
fstate = OPTION_NORMAL
|
||||
f = open(filename, "r")
|
||||
|
|
|
@ -613,9 +613,6 @@ int LogfileManager::registerTransaction (TRI_voc_tid_t transactionId) {
|
|||
|
||||
WRITE_LOCKER(_transactionsLock);
|
||||
|
||||
// make room for at least one more failed transaction
|
||||
_failedTransactions.reserve(_failedTransactions.size() + 1);
|
||||
|
||||
// insert into currently running list of transactions
|
||||
_transactions.emplace(transactionId, std::move(p));
|
||||
TRI_ASSERT_EXPENSIVE(lastCollectedId <= lastSealedId);
|
||||
|
|
Loading…
Reference in New Issue