Skip to content

Commit

Permalink
fix(@angular/cli): fix doc command to work with new angular.io
Browse files Browse the repository at this point in the history
- change the URL for the API search
- use google search when --search option is true, since angular.io doesn't have a search page anymore
- improve the help and doc of the doc command
  • Loading branch information
jnizet authored and Brocco committed Jul 19, 2017
1 parent 6015f07 commit 6ca6a5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion docs/documentation/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,16 @@
# ng doc

## Overview
`ng doc [search term]` Opens the official Angular documentation for a given keyword on [angular.io](https://angular.io).
`ng doc [search term]` Opens the official Angular API documentation for a given keyword on [angular.io](https://angular.io).

## Options

<details>
<summary>search</summary>
<p>
<code>--search</code> (alias: <code>-s</code>) <em>default value: false</em>
</p>
<p>
Search for the keyword in the whole [angular.io](https://angular.io) documentation instead of just the API.
</p>
</details>
4 changes: 2 additions & 2 deletions packages/@angular/cli/commands/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export interface DocOptions {

const DocCommand = Command.extend({
name: 'doc',
description: 'Opens the official Angular documentation for a given keyword.',
description: 'Opens the official Angular API documentation for a given keyword.',
works: 'everywhere',
availableOptions: [
{
name: 'search',
aliases: ['s'],
type: Boolean,
default: false,
description: 'Search docs instead of api.'
description: 'Search whole angular.io instead of just api.'
}
],

Expand Down
4 changes: 2 additions & 2 deletions packages/@angular/cli/tasks/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const opn = require('opn');

export const DocTask: any = Task.extend({
run: function(keyword: string, search: boolean) {
const searchUrl = search ? `https://angular.io/search/#stq=${keyword}&stp=1` :
`https://angular.io/docs/ts/latest/api/#!?query=${keyword}`;
const searchUrl = search ? `https://www.google.com/search?q=site%3Aangular.io+${keyword}` :
`https://angular.io/api?query=${keyword}`;

return opn(searchUrl, { wait: false });
}
Expand Down

0 comments on commit 6ca6a5e

Please sign in to comment.