Skip to content

Commit

Permalink
feat(@angular/cli): ng doc accepts a version flag
Browse files Browse the repository at this point in the history
With this commit, we can now specify a `version`
for the `ng doc` command

    ng doc --version 6
    ng doc -v 6

and this will open `v6.angular.io` instead of `angular.io`.
The default domain is still used
if no version is specified.

Refs #12365
  • Loading branch information
LakhyariMs committed Jun 15, 2019
1 parent 7e537c1 commit 7d6732c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/angular/cli/commands/doc-impl.ts
Expand Up @@ -19,9 +19,17 @@ export class DocCommand extends Command<DocCommandSchema> {

return 0;
}
let searchUrl = `https://angular.io/api?query=${options.keyword}`;

let domain = 'angular.io';

if (options.version) {
domain = `v${options.version}.angular.io`;
}

let searchUrl = `https://${domain}/api?query=${options.keyword}`;

if (options.search) {
searchUrl = `https://www.google.com/search?q=site%3Aangular.io+${options.keyword}`;
searchUrl = `https://www.google.com/search?q=site%3A${domain}+${options.keyword}`;
}

// We should wrap `open` in a new Promise because `open` is already resolved
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/cli/commands/doc.json
Expand Up @@ -25,6 +25,11 @@
"type": "boolean",
"default": false,
"description": "When true, searches all of angular.io. Otherwise, searches only API reference documentation."
},
"version" : {
"aliases": ["v"],
"type": "string",
"description": "Contains the version of Angular to use for the documentation."
}
},
"required": [
Expand Down

0 comments on commit 7d6732c

Please sign in to comment.