mirror of
https://github.com/appium/appium.git
synced 2026-05-23 04:18:53 -05:00
added a doc generator for parser and new docs
This commit is contained in:
+4
-2
@@ -12,11 +12,10 @@ var path = require('path')
|
||||
, buildAndroidBootstrap = gruntHelpers.buildAndroidBootstrap
|
||||
, buildAndroidApp = gruntHelpers.buildAndroidApp
|
||||
, installAndroidApp = gruntHelpers.installAndroidApp
|
||||
, generateServerDocs = gruntHelpers.generateServerDocs
|
||||
, runTestsWithServer = gruntHelpers.runTestsWithServer;
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
|
||||
grunt.initConfig({
|
||||
jshint: {
|
||||
all: ['*.js', 'app/*.js', 'app/test/unit/*.js', 'instruments/*.js', 'test/functional/*.js', 'test/unit/*.js', 'test/functional/appium/*.js', 'test/functional/testapp/*.js', 'test/functional/uicatalog/*.js', 'test/functional/webview/*.js', 'test/helpers/*.js', 'app/uiauto/appium/app.js', 'app/uiauto/appium/binding.js', 'app/uiauto/element.js', 'app/uiauto/appium/utility.js', 'app/uiauto/lib/instruments_client.js', 'app/uiauto/lib/status.js']
|
||||
@@ -122,4 +121,7 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('installAndroidApp', function(appName) {
|
||||
installAndroidApp(grunt, appName, this.async());
|
||||
});
|
||||
grunt.registerTask('docs', function() {
|
||||
generateServerDocs(grunt, this.async());
|
||||
});
|
||||
};
|
||||
|
||||
+111
-94
@@ -1,7 +1,114 @@
|
||||
"use strict";
|
||||
var ap = require('argparse').ArgumentParser
|
||||
, pkgObj = require("../package")
|
||||
;
|
||||
, _ = require("underscore");
|
||||
|
||||
var args = [
|
||||
[['--app'] , {
|
||||
required: false
|
||||
, help: 'IOS: abs path to simulator-compiled .app file or the bundle_id of the desired target on device; Android: abs path to .apk file'
|
||||
, example: "/abs/path/to/my.app"
|
||||
, nargs: 1
|
||||
}],
|
||||
|
||||
[['-V', '--verbose'], {
|
||||
required: false
|
||||
, help: 'Get verbose logging output'
|
||||
, nargs: 0
|
||||
}],
|
||||
|
||||
[['-U', '--udid'] , {
|
||||
required: false
|
||||
, example: "1adsf-sdfas-asdf-123sdf"
|
||||
, help: '(IOS-only) Unique device identifier of the connected physical device'
|
||||
, nargs: 0
|
||||
}],
|
||||
|
||||
[['-a', '--address'] , {
|
||||
defaultValue: '0.0.0.0'
|
||||
, required: false
|
||||
, example: "0.0.0.0"
|
||||
, help: 'IP Address to listen on'
|
||||
, nargs: 1
|
||||
}],
|
||||
|
||||
[['-p', '--port'] , {
|
||||
defaultValue: 4723
|
||||
, required: false
|
||||
, example: "4723"
|
||||
, help: 'Port to listen on'
|
||||
, nargs: 1
|
||||
}],
|
||||
|
||||
[['-r', '--remove'] , {
|
||||
defaultValue: true
|
||||
, required: false
|
||||
, help: '(IOS-only) Remove Instruments trace directories'
|
||||
, nargs: 0
|
||||
}],
|
||||
|
||||
[['-s', '--reset'] , {
|
||||
defaultValue: true
|
||||
, required: false
|
||||
, help: 'Reset app state after each session (IOS: delete plist; Android: ' +
|
||||
'install app before session and uninstall after session)'
|
||||
, nargs: 0
|
||||
}],
|
||||
|
||||
[['-l', '--launch'] , {
|
||||
defaultValue: false
|
||||
, required: false
|
||||
, help: 'Pre-launch the application before allowing the first session ' +
|
||||
'(Requires --app and, for Android, --app-pkg and --app-activity)'
|
||||
, nargs: 0
|
||||
}],
|
||||
|
||||
[['-g', '--log'] , {
|
||||
defaultValue: null
|
||||
, required: false
|
||||
, example: "/path/to/appium.log"
|
||||
, help: 'Log output to this file instead of stdout'
|
||||
, nargs: 1
|
||||
}],
|
||||
|
||||
[['-G', '--webhook'] , {
|
||||
defaultValue: null
|
||||
, required: false
|
||||
, example: "localhost:9876"
|
||||
, help: 'Also send log output to this HTTP listener'
|
||||
, nargs: 1
|
||||
}],
|
||||
|
||||
[['-w', '--warp'] , {
|
||||
defaultValue: false
|
||||
, required: false
|
||||
, help: '(IOS-only) IOS has a weird built-in unavoidable sleep. One way ' +
|
||||
'around this is to speed up the system clock. Use this time warp ' +
|
||||
'hack to speed up test execution (WARNING, actually alters clock, ' +
|
||||
'could be bad news bears!)'
|
||||
, nargs: 0
|
||||
}],
|
||||
|
||||
[['--app-pkg'], {
|
||||
dest: 'androidPackage'
|
||||
, defaultValue: null
|
||||
, required: false
|
||||
, example: "com.example.android.myApp"
|
||||
, help: "(Android-only) Java package of the Android app you want to run " +
|
||||
"(e.g., com.example.android.myApp)"
|
||||
, nargs: 1
|
||||
}],
|
||||
|
||||
[['--app-activity'], {
|
||||
dest: 'androidActivity'
|
||||
, defaultValue: 'MainActivity'
|
||||
, required: false
|
||||
, example: "MainActivity"
|
||||
, help: "(Android-only) Activity name for the Android activity you want " +
|
||||
"to launch from your package (e.g., MainActivity)"
|
||||
, nargs: 1
|
||||
}],
|
||||
];
|
||||
|
||||
// Setup all the command line argument parsing
|
||||
module.exports = function() {
|
||||
@@ -11,101 +118,11 @@ module.exports = function() {
|
||||
description: 'A webdriver-compatible server for use with native and hybrid iOS and Android applications.'
|
||||
});
|
||||
|
||||
parser.addArgument( ['--app'] , {
|
||||
required: false
|
||||
, help: 'IOS: abs path to simulator-compiled .app file or the bundle_id of the desired target on device; Android: abs path to .apk file'
|
||||
, nargs: 1
|
||||
_.each(args, function(arg) {
|
||||
parser.addArgument(arg[0], arg[1]);
|
||||
});
|
||||
|
||||
parser.addArgument(['-V', '--verbose'], {
|
||||
required: false
|
||||
, help: 'Get verbose logging output'
|
||||
, nargs: 0
|
||||
});
|
||||
parser.addArgument(['-U', '--udid'] , {
|
||||
required: false
|
||||
, help: '(IOS-only) Unique device identifier of the connected physical device'
|
||||
, nargs: 0
|
||||
});
|
||||
|
||||
parser.addArgument(['-a', '--address'] , {
|
||||
defaultValue: '127.0.0.1'
|
||||
, required: false
|
||||
, help: 'IP Address to listen on'
|
||||
, nargs: 1
|
||||
});
|
||||
|
||||
parser.addArgument(['-p', '--port'] , {
|
||||
defaultValue: 4723
|
||||
, required: false
|
||||
, help: 'Port to listen on'
|
||||
, nargs: 1
|
||||
});
|
||||
|
||||
parser.addArgument(['-r', '--remove'] , {
|
||||
defaultValue: true
|
||||
, required: false
|
||||
, help: '(IOS-only) Remove Instruments trace directories'
|
||||
, nargs: 0
|
||||
});
|
||||
|
||||
parser.addArgument(['-s', '--reset'] , {
|
||||
defaultValue: true
|
||||
, required: false
|
||||
, help: 'Reset app state after each session (IOS: delete plist; Android: ' +
|
||||
'install app before session and uninstall after session)'
|
||||
, nargs: 0
|
||||
});
|
||||
|
||||
parser.addArgument(['-l', '--launch'] , {
|
||||
defaultValue: false
|
||||
, required: false
|
||||
, help: 'Pre-launch the application before allowing the first session ' +
|
||||
'(Requires --app and, for Android, --app-pkg and --app-activity)'
|
||||
, nargs: 0
|
||||
});
|
||||
|
||||
parser.addArgument(['-g', '--log'] , {
|
||||
defaultValue: null
|
||||
, required: false
|
||||
, help: 'Log output to this file instead of stdout'
|
||||
, nargs: 1
|
||||
});
|
||||
|
||||
parser.addArgument(['-G', '--webhook'] , {
|
||||
defaultValue: null
|
||||
, required: false
|
||||
, help: 'Also send log output to this HTTP listener'
|
||||
, nargs: 1
|
||||
});
|
||||
|
||||
parser.addArgument(['-w', '--warp'] , {
|
||||
defaultValue: false
|
||||
, required: false
|
||||
, help: '(IOS-only) IOS has a weird built-in unavoidable sleep. One way ' +
|
||||
'around this is to speed up the system clock. Use this time warp ' +
|
||||
'hack to speed up test execution (WARNING, actually alters clock, ' +
|
||||
'could be bad news bears!)'
|
||||
, nargs: 0
|
||||
});
|
||||
|
||||
parser.addArgument(['--app-pkg'], {
|
||||
dest: 'androidPackage'
|
||||
, defaultValue: null
|
||||
, required: false
|
||||
, help: "(Android-only) Java package of the Android app you want to run " +
|
||||
"(e.g., com.example.android.myApp)"
|
||||
, nargs: 1
|
||||
});
|
||||
|
||||
parser.addArgument(['--app-activity'], {
|
||||
dest: 'androidActivity'
|
||||
, defaultValue: 'MainActivity'
|
||||
, required: false
|
||||
, help: "(Android-only) Activity name for the Android activity you want " +
|
||||
"to launch from your package (e.g., MainActivity)"
|
||||
, nargs: 1
|
||||
});
|
||||
parser.rawArgs = args;
|
||||
|
||||
return parser;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
Appium server arguments
|
||||
==========
|
||||
|
||||
Usage: `node server.js [flags]`
|
||||
|
||||
### Server flags
|
||||
|
||||
|Flag|Required?|Default|Description|Example||----|---------|-------|-----------|-------||`--app`|no|null|IOS: abs path to simulator-compiled .app file or the bundle_id of the desired target on device; Android: abs path to .apk file|`--app /abs/path/to/my.app`|
|
||||
|`-V`, `--verbose`|no|null|Get verbose logging output|``|
|
||||
|`-U`, `--udid`|no|null|(IOS-only) Unique device identifier of the connected physical device|`--udid 1adsf-sdfas-asdf-123sdf`|
|
||||
|`-a`, `--address`|no|0.0.0.0|IP Address to listen on|`--address 0.0.0.0`|
|
||||
|`-p`, `--port`|no|4723|Port to listen on|`--port 4723`|
|
||||
|`-r`, `--remove`|no|true|(IOS-only) Remove Instruments trace directories|``|
|
||||
|`-s`, `--reset`|no|true|Reset app state after each session (IOS: delete plist; Android: install app before session and uninstall after session)|``|
|
||||
|`-l`, `--launch`|no|false|Pre-launch the application before allowing the first session (Requires --app and, for Android, --app-pkg and --app-activity)|``|
|
||||
|`-g`, `--log`|no|null|Log output to this file instead of stdout|`--log /path/to/appium.log`|
|
||||
|`-G`, `--webhook`|no|null|Also send log output to this HTTP listener|`--webhook localhost:9876`|
|
||||
|`-w`, `--warp`|no|false|(IOS-only) IOS has a weird built-in unavoidable sleep. One way around this is to speed up the system clock. Use this time warp hack to speed up test execution (WARNING, actually alters clock, could be bad news bears!)|``|
|
||||
|`--app-pkg`|no|null|(Android-only) Java package of the Android app you want to run (e.g., com.example.android.myApp)|`--app-pkg com.example.android.myApp`|
|
||||
|`--app-activity`|no|MainActivity|(Android-only) Activity name for the Android activity you want to launch from your package (e.g., MainActivity)|`--app-activity MainActivity`|
|
||||
@@ -10,6 +10,7 @@ var _ = require("underscore")
|
||||
, prompt = require('prompt')
|
||||
, exec = require('child_process').exec
|
||||
, spawn = require('child_process').spawn
|
||||
, parser = require('./app/parser')
|
||||
, fs = require('fs');
|
||||
|
||||
module.exports.startAppium = function(appName, verbose, readyCb, doneCb) {
|
||||
@@ -327,3 +328,33 @@ module.exports.installAndroidApp = function(grunt, appName, cb) {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.generateServerDocs = function(grunt, cb) {
|
||||
var p = parser();
|
||||
var docFile = path.resolve(__dirname, "docs/server-args.md");
|
||||
var md = "Appium server arguments\n==========\n\n";
|
||||
md += "Usage: `node server.js [flags]`\n\n";
|
||||
md += "### Server flags\n\n";
|
||||
md += "|Flag|Required?|Default|Description|Example|";
|
||||
md += "|----|---------|-------|-----------|-------|";
|
||||
_.each(p.rawArgs, function(arg) {
|
||||
var argNames = arg[0];
|
||||
var exampleArg = typeof arg[0][1] === "undefined" ? arg[0][0] : arg[0][1];
|
||||
var argOpts = arg[1];
|
||||
md += "|`" + argNames.join("`, `") + "`";
|
||||
md += "|" + (argOpts.required ? "yes" : "no");
|
||||
md += "|" + ((typeof argOpts.defaultValue === "undefined") ? "" : argOpts.defaultValue);
|
||||
md += "|" + argOpts.help;
|
||||
md += "|`" + ((typeof argOpts.example === "undefined") ? "" : exampleArg + " " + argOpts.example) + "`";
|
||||
md += "|\n";
|
||||
});
|
||||
fs.writeFile(docFile, md, function(err) {
|
||||
if (err) {
|
||||
console.log(err.stack);
|
||||
grunt.fatal(err);
|
||||
} else {
|
||||
grunt.log.write("New docs written! Don't forget to commit and push");
|
||||
cb();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user