Skip to content

feat(@angular/cli): ng doc accepts a version flag #14788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/angular/cli/commands/doc-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@ export class DocCommand extends Command<DocCommandSchema> {

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

let domain = 'angular.io';

if (options.version) {
if (options.version == 'next') {
domain = 'next.angular.io';
} else {
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
15 changes: 15 additions & 0 deletions packages/angular/cli/commands/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@
"type": "boolean",
"default": false,
"description": "When true, searches all of angular.io. Otherwise, searches only API reference documentation."
},
"version" : {
"anyOf": [
{
"const" : 2
},
{
"type" : "integer",
"minimum": 4
},
{
"const": "next"
}
],
"description": "Contains the version of Angular to use for the documentation."
}
},
"required": [
Expand Down