File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11const Command = require ( '../ember-cli/lib/models/command' ) ;
22import { DocTask } from '../tasks/doc' ;
33
4+ export interface DocOptions {
5+ search ?: boolean ;
6+ }
7+
48const 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
Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ const Task = require('../ember-cli/lib/models/task');
22const opn = require ( 'opn' ) ;
33
44export 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} ) ;
You can’t perform that action at this time.
0 commit comments