Skip to content

Commit 5e39361

Browse files
sumitarorahansl
authored andcommitted
feat(@angular/cli): adding option to search docs as well
1 parent aa958a6 commit 5e39361

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

packages/@angular/cli/commands/doc.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
const Command = require('../ember-cli/lib/models/command');
22
import { DocTask } from '../tasks/doc';
33

4+
export interface DocOptions {
5+
search?: boolean;
6+
}
7+
48
const DocCommand = Command.extend({
59
name: 'doc',
610
description: 'Opens the official Angular documentation for a given keyword.',
711
works: 'everywhere',
12+
availableOptions: [
13+
{
14+
name: 'search',
15+
aliases: ['s'],
16+
type: Boolean,
17+
default: false,
18+
description: 'Search docs instead of api.'
19+
}
20+
],
821

922
anonymousOptions: [
1023
'<keyword>'
1124
],
1225

13-
run: function(_commandOptions: any, rawArgs: Array<string>) {
26+
run: function(commandOptions: DocOptions, rawArgs: Array<string>) {
1427
const keyword = rawArgs[0];
1528

1629
const docTask = new DocTask({
1730
ui: this.ui,
1831
project: this.project
1932
});
2033

21-
return docTask.run(keyword);
34+
return docTask.run(keyword, commandOptions.search);
2235
}
2336
});
2437

packages/@angular/cli/tasks/doc.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ const Task = require('../ember-cli/lib/models/task');
22
const opn = require('opn');
33

44
export const DocTask: any = Task.extend({
5-
run: function(keyword: string) {
6-
const searchUrl = `https://angular.io/docs/ts/latest/api/#!?query=${keyword}`;
5+
run: function(keyword: string, search: boolean) {
6+
const searchUrl = search ? `https://angular.io/search/#stq=${keyword}&stp=1` :
7+
`https://angular.io/docs/ts/latest/api/#!?query=${keyword}`;
8+
79
return opn(searchUrl, { wait: false });
810
}
911
});

0 commit comments

Comments
 (0)