Skip to content

Commit a9dc685

Browse files
committed
feat(doc): add "ng doc" command
1 parent 5da51b0 commit a9dc685

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

addon/ng2/commands/doc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* jshint node: true */
2+
'use strict';
3+
4+
var Command = require('ember-cli/lib/models/command');
5+
var DocTask = require('../tasks/doc');
6+
7+
module.exports = Command.extend({
8+
name: 'doc',
9+
description: 'Opens the official Angular documentation for a given keyword.',
10+
works: 'everywhere',
11+
anonymousOptions: [
12+
'<keyword>'
13+
],
14+
run: function(commandOptions, rawArgs) {
15+
var keyword = rawArgs[0];
16+
17+
var docTask = new DocTask({
18+
ui: this.ui,
19+
analytics: this.analytics,
20+
project: this.project
21+
});
22+
23+
return docTask.run(keyword);
24+
}
25+
});

addon/ng2/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module.exports = {
1313
'lint': require('./commands/lint'),
1414
'format': require('./commands/format'),
1515
'version': require('./commands/version'),
16-
'completion': require('./commands/completion')
16+
'completion': require('./commands/completion'),
17+
'doc': require('./commands/doc')
1718
};
1819
}
1920
};

addon/ng2/tasks/doc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* jshint node: true */
2+
'use strict';
3+
4+
var Task = require('ember-cli/lib/models/task');
5+
var opn = require('opn');
6+
7+
module.exports = Task.extend({
8+
run: function(keyword) {
9+
var searchUrl = 'https://angular.io/docs/ts/latest/api/#!?apiFilter=' + keyword;
10+
return opn(searchUrl);
11+
}
12+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"leek": "0.0.21",
4444
"lodash": "^4.6.1",
4545
"multidep": "^2.0.0",
46+
"opn": "4.0.1",
4647
"resolve": "^1.1.7",
4748
"shelljs": "^0.6.0",
4849
"silent-error": "^1.0.0",

0 commit comments

Comments
 (0)