Skip to content

Commit 58599e1

Browse files
LakhyariMsmgechev
authored andcommitted
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 #12365
1 parent cc91088 commit 58599e1

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

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

+14-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ 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+
if (options.version == 'next') {
27+
domain = 'next.angular.io';
28+
} else {
29+
domain = `v${options.version}.angular.io`;
30+
}
31+
}
32+
33+
let searchUrl = `https://${domain}/api?query=${options.keyword}`;
34+
2335
if (options.search) {
24-
searchUrl = `https://www.google.com/search?q=site%3Aangular.io+${options.keyword}`;
36+
searchUrl = `https://www.google.com/search?q=site%3A${domain}+${options.keyword}`;
2537
}
2638

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

packages/angular/cli/commands/doc.json

+15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@
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+
"anyOf": [
31+
{
32+
"const" : 2
33+
},
34+
{
35+
"type" : "integer",
36+
"minimum": 4
37+
},
38+
{
39+
"const": "next"
40+
}
41+
],
42+
"description": "Contains the version of Angular to use for the documentation."
2843
}
2944
},
3045
"required": [

0 commit comments

Comments
 (0)