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

refactor redundant/verbose code in player.js #3597

Merged
merged 2 commits into from
Sep 29, 2016
Merged

refactor redundant/verbose code in player.js #3597

merged 2 commits into from
Sep 29, 2016

Conversation

brandonocasey
Copy link
Contributor

Description

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

ToDo

Find a way to generate documentation for all the methods that are now dynamic, without compromising on the size of video.js

@gkatsev
Copy link
Member

gkatsev commented Sep 2, 2016

I don't think the changes to player.js here are worth the limited savings. We lose an easy way to document the functions, plus, there's a performance and memory hit here since we're creating a new functions each time a player is created. The player is the most important class in the project so making sure that it's well documented is essential.

@brandonocasey
Copy link
Contributor Author

we should still be able to document the methods, and I can add all of this to the prototype rather than in the constructor

@pam
Copy link

pam commented Sep 2, 2016

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 8599123d7af103dc2f90d8ee2be31556d6556be2
Build details: https://travis-ci.org/pam/video.js/builds/157191006

(Please note that this is a fully automated comment.)

*
* @event ended
*/
Player.prototype.handleTechEnded_; // eslint-disable-line
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function actually exists

Copy link
Member

Choose a reason for hiding this comment

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

Are we not losing the @event ended here with this removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are but I think this is the same or similar to: #3630 as @event just attached the event to the global scope in the docs. I can put @triggers on the method if we want though

Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep it but make sure it gets updated as part of #3630.

@pam
Copy link

pam commented Sep 2, 2016

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 15cc4c0ef4da33471562a4f3ee34e8dd90dce4f2
Build details: https://travis-ci.org/pam/video.js/builds/157203479

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Sep 2, 2016

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 37cd7780179df233f5a76d161bd8eb440eb497d2
Build details: https://travis-ci.org/pam/video.js/builds/157204402

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Sep 2, 2016

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: e1eaf4bdc7ec9310f81daf3b45473c1db48e69f5
Build details: https://travis-ci.org/pam/video.js/builds/157211626

(Please note that this is a fully automated comment.)

/**
* Fired when the player has initial duration and dimension information
*
* @event loadedmetadata
* Player.prototype.handleLoadedMetaData_
Copy link
Member

Choose a reason for hiding this comment

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

Missing @method here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah good catch

Copy link
Member

Choose a reason for hiding this comment

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

We probably don't want to have @method here. We don't want these to show up as documentation. These stubs specifically are used to document the events that the player listens to but are otherwise private methods. Adding a @private, I think, will then prevent the event from being displayed in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

going to add @Private

@misteroneill
Copy link
Member

@gkatsev Made a good point. We should make sure that anything with a trailing underscore is marked as @private because we don't want it showing up in docs.

elTracks.addEventListener('removetrack', this[`handle${capitalType}TrackRemove_`]);
this[`removeOld${capitalType}Tracks_`] = (e) => this.removeOldTracks_(techTracks, elTracks);

// Remove (native) trackts that are not used anymore
Copy link
Member

Choose a reason for hiding this comment

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

As long as we're in here, the "trackts" typo could be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch

Copy link
Member

Choose a reason for hiding this comment

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

This still needs an update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was changed in the other PR #3593, and I will rebase it when it is merged

Copy link
Member

Choose a reason for hiding this comment

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

Ah cool. Forgot that it included the other PR.

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

A few questions.

@@ -60,7 +140,6 @@ import './tech/html5.js';
* @param {Element} tag The original video tag used for configuring options
* @param {Object=} options Object of option names and values
* @param {Function=} ready Ready callback function
* @extends Component
Copy link
Member

Choose a reason for hiding this comment

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

does this get picked up automatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah from my testing with jsdoc it does

*/
Player.prototype.handleLoadedMetaData_; // eslint-disable-line
Copy link
Member

Choose a reason for hiding this comment

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

you don't need the method stub for jsdoc to pick this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no you don't, jsdoc assumes that it is a dynamic method

/**
* Fired when the player has initial duration and dimension information
*
* @event loadedmetadata
* @private
Copy link
Member

Choose a reason for hiding this comment

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

does @private still keep the events in the doc output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me double check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no id does not keep the events in the docs, and it seems like our event format may even be off http://usejsdoc.org/tags-event.html

Copy link
Member

Choose a reason for hiding this comment

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

Might be the old format or something? I would vote for removing the @private and filing a separate issue for fixing the @event doclets.

Copy link
Contributor Author

@brandonocasey brandonocasey Sep 20, 2016

Choose a reason for hiding this comment

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

yeah it seems like @event should be it's own seperate tag, it does not show up even with @private removed I think that we just need lots of documentation updates at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this seems to be format that we would want it in, although it still looks a bit strange when I generate the docs, I think we need to do any more documentation changes/updates in another PR

/**
 * Fires loadedmetadata from the tech
 *
 * @fires Player#loadedmetadata
 * @method Player.prototype.handleLoadedMetaData_
 * @private
 */

/**
 * Fired when the player has initial duration and dimension information
 *
 * @event Player#loadedmetadata
 * @type {Event}
 */

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. Want to open a new issue with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

LGTM.
Test fails because of the firefox issue.

@gkatsev gkatsev modified the milestones: 5.13, 5.12 Sep 27, 2016
@gkatsev gkatsev merged commit ae3e277 into videojs:master Sep 29, 2016
@brandonocasey brandonocasey deleted the chore/refactor-player-js branch December 6, 2016 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants