mirror of https://gitee.com/bigwinds/arangodb
Add a js-scripted way to invoke the example generator - for now it needs a running arangod instance.
This commit is contained in:
parent
7b081fb6f3
commit
2c099b8348
|
@ -63,18 +63,18 @@ examples:
|
|||
@rm -f /tmp/arangodb.examples
|
||||
|
||||
python @srcdir@/Documentation/Scripts/generateExamples.py \
|
||||
--output-dir @builddir@/Documentation/Examples \
|
||||
--only-thisone "$(FILTER_EXAMPLE)" \
|
||||
--arangosh-setup @srcdir@/Documentation/Examples/setup-arangosh.js \
|
||||
@srcdir@/js/actions \
|
||||
@srcdir@/js/client \
|
||||
@srcdir@/js/common \
|
||||
@srcdir@/js/server \
|
||||
@srcdir@/js/apps/system/_api/gharial/APP \
|
||||
@srcdir@/Documentation/Books/Users \
|
||||
@srcdir@/arangod/RestHandler \
|
||||
@srcdir@/arangod/V8Server \
|
||||
> /tmp/arangosh.examples.js
|
||||
--outputDir @builddir@/Documentation/Examples \
|
||||
--onlyThisone "$(FILTER_EXAMPLE)" \
|
||||
--outputFile /tmp/arangosh.examples.js \
|
||||
--arangoshSetup @srcdir@/Documentation/Examples/setup-arangosh.js \
|
||||
@srcdir@/js/actions \
|
||||
@srcdir@/js/client \
|
||||
@srcdir@/js/common \
|
||||
@srcdir@/js/server \
|
||||
@srcdir@/js/apps/system/_api/gharial/APP \
|
||||
@srcdir@/Documentation/Books/Users \
|
||||
@srcdir@/arangod/RestHandler \
|
||||
@srcdir@/arangod/V8Server
|
||||
|
||||
if test -z "$(server.endpoint)"; then \
|
||||
$(MAKE) start-server PID=$(PID) \
|
||||
|
|
|
@ -126,6 +126,7 @@ OPTION_NORMAL = 0
|
|||
OPTION_ARANGOSH_SETUP = 1
|
||||
OPTION_OUTPUT_DIR = 2
|
||||
OPTION_FILTER = 3
|
||||
OPTION_OUTPUT_FILE = 4
|
||||
|
||||
fstate = OPTION_NORMAL
|
||||
|
||||
|
@ -445,16 +446,18 @@ def loopDirectories():
|
|||
filenames = []
|
||||
|
||||
for filename in argv:
|
||||
if filename == "--arangosh-setup":
|
||||
if filename == "--arangoshSetup":
|
||||
fstate = OPTION_ARANGOSH_SETUP
|
||||
continue
|
||||
if filename == "--only-thisone":
|
||||
if filename == "--onlyThisOne":
|
||||
fstate = OPTION_FILTER
|
||||
continue
|
||||
if filename == "--output-dir":
|
||||
if filename == "--outputDir":
|
||||
fstate = OPTION_OUTPUT_DIR
|
||||
continue
|
||||
|
||||
if filename == "--outputFile":
|
||||
fstate = OPTION_OUTPUT_FILE
|
||||
continue
|
||||
if fstate == OPTION_NORMAL:
|
||||
if os.path.isdir(filename):
|
||||
for root, dirs, files in os.walk(filename):
|
||||
|
@ -481,6 +484,10 @@ def loopDirectories():
|
|||
elif fstate == OPTION_OUTPUT_DIR:
|
||||
fstate = OPTION_NORMAL
|
||||
OutputDir = filename
|
||||
elif fstate == OPTION_OUTPUT_FILE:
|
||||
fstate = OPTION_NORMAL
|
||||
sys.stdout = open(filename, 'w')
|
||||
|
||||
for filename in filenames:
|
||||
if (filename.find("#") < 0):
|
||||
f = open(filename, "r")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
run
|
|
@ -0,0 +1,76 @@
|
|||
/*jshint globalstrict:false, unused:false */
|
||||
/*global start_pretty_print */
|
||||
|
||||
var fs = require("fs");
|
||||
var internal = require("internal");
|
||||
var executeExternalAndWait = internal.executeExternalAndWait;
|
||||
var print = internal.print;
|
||||
|
||||
var documentationSourceDirs = [
|
||||
fs.join(fs.makeAbsolute(''), "Documentation/Examples/setup-arangosh.js"),
|
||||
fs.join(fs.makeAbsolute(''), "js/actions"),
|
||||
fs.join(fs.makeAbsolute(''), "js/client"),
|
||||
fs.join(fs.makeAbsolute(''), "js/common"),
|
||||
fs.join(fs.makeAbsolute(''), "js/server"),
|
||||
fs.join(fs.makeAbsolute(''), "js/apps/system/_api/gharial/APP"),
|
||||
fs.join(fs.makeAbsolute(''), "Documentation/Books/Users"),
|
||||
fs.join(fs.makeAbsolute(''), "arangod/RestHandler"),
|
||||
fs.join(fs.makeAbsolute(''), "arangod/V8Server")];
|
||||
|
||||
|
||||
|
||||
|
||||
var theScript = 'Documentation/Scripts/generateExamples.py';
|
||||
|
||||
var scriptArguments = {
|
||||
'outputDir': fs.join(fs.makeAbsolute(''), "Documentation/Examples"),
|
||||
'outputFile': '/tmp/arangosh.examples.js'
|
||||
};
|
||||
|
||||
function main (argv) {
|
||||
"use strict";
|
||||
var thePython = 'python';
|
||||
var test = argv[1];
|
||||
var options = {};
|
||||
var serverEndpoint = '';
|
||||
var runLocaly = true;
|
||||
|
||||
try {
|
||||
options = internal.parseArgv(argv, 1);
|
||||
}
|
||||
catch (x) {
|
||||
print("failed to parse the options: " + x.message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (options.hasOwnProperty('withPython')) {
|
||||
thePython = options.withPython;
|
||||
}
|
||||
|
||||
if (options.hasOwnProperty('onlyThisOne')) {
|
||||
scriptArguments['onlyThisOne'] = options.onlyThisOne;
|
||||
}
|
||||
|
||||
if (options.hasOwnProperty('server.endpoint')) {
|
||||
runLocaly = false;
|
||||
serverEndpoint = options['server.endpoint'];
|
||||
}
|
||||
var args = [theScript].concat(internal.toArgv(scriptArguments));
|
||||
args = args.concat(['--arangoshSetup']);
|
||||
args = args.concat(documentationSourceDirs);
|
||||
|
||||
internal.print(JSON.stringify(args));
|
||||
|
||||
var res = executeExternalAndWait(thePython, args);
|
||||
|
||||
|
||||
var arangoshArgs = {
|
||||
'configuration': fs.join(fs.makeAbsolute(''), 'etc', 'relative', 'arangosh.conf'),
|
||||
'server.password': "",
|
||||
'server.endpoint': serverEndpoint,
|
||||
'javascript.execute': scriptArguments.outputFile
|
||||
};
|
||||
|
||||
res = executeExternalAndWait('bin/arangosh', internal.toArgv(arangoshArgs));
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue