Skip to content

Remove name parameter from animation directive. #1715

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 14, 2018

Conversation

gspencergoog
Copy link
Collaborator

This PR removes the required first argument for the {@animation...} directive, making it into an optional argument.

It also builds a way to parse arguments for directives that is more consistent, and leverages the Dart arg parser. The arguments may be quoted in order to contain spaces if needed. Updates _injectExamples to use this parser as well as the _injectAnimations function.

The old animation directive form is still supported, but will give a deprecation warning if used. I also added a new type of warning for this: PackageWarning.deprecated.

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Jun 13, 2018
return option + (match[3] ?? '') + (match[4] ?? '');
});

return argParser.parse(args);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ArgParserExceptions thrown here probably should not be fatal and should instead emit some sort of helpful warning. You might have to carry along some extra data into _parseArgs to make that useful without reflection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point . Would it be enough to just call warn with invalidParameter here (which is an error) and return an empty ArgResults in the case of an ArgParserException?

if (positionalArgs.length == 4) {
// Supports the original form of the animation tag for backward
// compatibility.
uniqueId = positionalArgs.removeAt(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will of course completely discard the name. Given that anchors do not actually work yet I suppose this is probably harmless?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is just is converting the old form of positional args (four args) to the new form (three args) by removing the first arg and using it as the uniqueName. The id is actually used in the injected HTML to control the playing of the video, so the uniqueness is required, as is the presence of some sort of id.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, got it.


/// Animation method with invalid name
///
/// {@animation 100 100 http://host/path/to/video.mp4 id=2isNot-A-ValidName}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding test cases for {@animation 250 250 id=outOfOrder http://host/path/to/video.mp4}
and {@animation 149 150 http://host/path/to/video.mp4 notId=unexpected} to validate more edge case behavior

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, added.

@gspencergoog gspencergoog force-pushed the remove_name branch 3 times, most recently from 17be545 to ea80a75 Compare June 14, 2018 00:26
if (positionalArgs.length == 4) {
// Supports the original form of the animation tag for backward
// compatibility.
uniqueId = positionalArgs.removeAt(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, got it.

@jcollins-g
Copy link
Contributor

I think github's commenting system doesn't like it when commits are replaced on the branch rather than added as the review takes place. github doesn't seem to want to offer anything except an emoji response to your reply on ArgParserException and throws some errors because it can't find the previous commit that was attached to.

@jcollins-g jcollins-g merged commit adbd2bb into dart-lang:master Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants