Skip to content

Commit 937ea5a

Browse files
committed
feat(@angular/cli): ng doc accepts a version flag
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 angular#12365
1 parent 7e537c1 commit 937ea5a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/angular/cli/commands/doc-impl.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@ export class DocCommand extends Command<DocCommandSchema> {
1919

2020
return 0;
2121
}
22-
let searchUrl = `https://angular.io/api?query=${options.keyword}`;
22+
23+
let domain = 'angular.io';
24+
25+
if (options.version) {
26+
domain = `v${options.version}.angular.io`;
27+
}
28+
29+
let searchUrl = `https://${domain}/api?query=${options.keyword}`;
30+
2331
if (options.search) {
24-
searchUrl = `https://www.google.com/search?q=site%3Aangular.io+${options.keyword}`;
32+
searchUrl = `https://www.google.com/search?q=site%3A${domain}+${options.keyword}`;
2533
}
2634

2735
// We should wrap `open` in a new Promise because `open` is already resolved

packages/angular/cli/commands/doc.json

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
"type": "boolean",
2626
"default": false,
2727
"description": "When true, searches all of angular.io. Otherwise, searches only API reference documentation."
28+
},
29+
"version" : {
30+
"aliases": ["v"],
31+
"type": "string",
32+
"description": "Contains the version of Angular to use for the documentation."
2833
}
2934
},
3035
"required": [

0 commit comments

Comments
 (0)