Skip to content
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

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

Merged
merged 1 commit into from Jun 17, 2019

Conversation

Projects
None yet
5 participants
@LakhyariMs
Copy link
Contributor

commented Jun 15, 2019

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

@googlebot googlebot added the cla: yes label Jun 15, 2019

@cexbrayat

This comment has been minimized.

Copy link
Contributor

commented Jun 15, 2019

Note to the team: this is a first time contributor, contributing to the CLI during the HackCommitPush conference, which aims to help developers to contribute to open source projects :)

@clydin
Copy link
Member

left a comment

Thank you for the contribution.

Can you add validation of the input?
The option should accept a number or “next” (no “v” prefix for this one). Several numbers are also invalid: 0, 1, and 3.

@cexbrayat

This comment has been minimized.

Copy link
Contributor

commented Jun 16, 2019

@clydin What do you think about:

"version" : {
  "aliases": ["v"],
  "anyOf": [
    {
      "type": "integer",
      "minimum": 2
    },
    {
      "const": "next"
    }
  ],
  "description": "Contains the version of Angular to use for the documentation."
}

and then test for 3 in code (I don't think we can exclude 3 in the schema?)
Ideally, we should also check that the version is not greater than the latest released, but that might be trickier. So I guess the logic:

if (options.version) {
  if (options.version === 'next') {
    domain =  'next.angular.io';
  } else if (+options.version !== 3) {
    domain = `v${options.version}.angular.io`;
  }
}

could be good enough for this first PR?

@clydin

This comment has been minimized.

Copy link
Member

commented Jun 16, 2019

Since 2 is the outlier, you could add it as a “const” in the anyOf and set the minimum in the integer section to 4. Looks good though.

@clydin

This comment has been minimized.

Copy link
Member

commented Jun 16, 2019

Also, if interested in a follow up PR, another nice feature that builds on this would be to automatically use the version installed within the project.

@cexbrayat

This comment has been minimized.

Copy link
Contributor

commented Jun 16, 2019

@clydin Thanks for the feedback!
Yes we were thinking about it, but I was unsure about the best way to get the Angular version installed in the project. What would you recommend?

@LakhyariMs Do you think you can update the PR with the changes Charles is suggesting?
Something like:

"version" : {
  "aliases": ["v"],
  "anyOf": [
    {
       "const": 2
    },
    {
      "type": "integer",
      "minimum": 4
    },
    {
      "const": "next"
    }
  ],
  "description": "Contains the version of Angular to use for the documentation."
}

and then something like:

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

@clydin clydin force-pushed the LakhyariMs:feat/doc branch from a5f52e6 to 0764450 Jun 17, 2019

@clydin

clydin approved these changes Jun 17, 2019

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

@clydin clydin force-pushed the LakhyariMs:feat/doc branch from 0764450 to 6ad0f03 Jun 17, 2019

@clydin

clydin approved these changes Jun 17, 2019

Copy link
Member

left a comment

Thank you again.
I squashed the PR for you so that it passes the validation check.
Also, removed the v alias as we would like to reserve that for a potential future verbose option on all commands.

@mgechev mgechev merged commit 58599e1 into angular:master Jun 17, 2019

13 checks passed

ci/angular: merge status All checks passed!
ci/angular: size No size change against base branch.
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: build-bazel Your tests passed on CircleCI!
Details
ci/circleci: e2e-cli Your tests passed on CircleCI!
Details
ci/circleci: e2e-cli-ivy Your tests passed on CircleCI!
Details
ci/circleci: install Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test Your tests passed on CircleCI!
Details
ci/circleci: test-large Your tests passed on CircleCI!
Details
ci/circleci: test-win Your tests passed on CircleCI!
Details
ci/circleci: validate Your tests passed on CircleCI!
Details
cla/google All necessary CLAs are signed

cexbrayat added a commit to cexbrayat/angular-cli that referenced this pull request Jun 27, 2019

feat(@angular/cli): ng doc uses angular core version by default
Follow-up to angular#14788 that allowed `ng doc --version 6`.
This commit enhances the doc command to use the current Angular version of the project by default, if no version is provided explicitely.

Fixes angular#12365

cexbrayat added a commit to cexbrayat/angular-cli that referenced this pull request Jun 27, 2019

feat(@angular/cli): ng doc uses angular core version by default
Follow-up to angular#14788 that allowed `ng doc --version 6`.
This commit enhances the doc command to use the current Angular version of the project by default, if no version is provided explicitely.

Fixes angular#12365

vikerman added a commit that referenced this pull request Jun 27, 2019

feat(@angular/cli): ng doc uses angular core version by default
Follow-up to #14788 that allowed `ng doc --version 6`.
This commit enhances the doc command to use the current Angular version of the project by default, if no version is provided explicitely.

Fixes #12365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.