Skip to content

Commit 7d4ed8a

Browse files
committed
feat(doc): add "ng doc" command
1 parent 8b6e80c commit 7d4ed8a

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

addon/ng2/commands/doc.ts

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

addon/ng2/index.js

+2-1
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.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as Task from 'ember-cli/lib/models/task';
2+
import * as opn from 'opn';
3+
4+
const DocTask = Task.extend({
5+
run: function(keyword:string) {
6+
var searchUrl = 'https://angular.io/docs/ts/latest/api/#!?apiFilter=' + keyword;
7+
return opn(searchUrl);
8+
}
9+
});
10+
11+
module.exports = DocTask;

package.json

+1
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)