-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Update the jsdoc comments to modern syntax - Part 1 #3694
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A number of grammar and other questions/concerns.
@@ -32,14 +35,19 @@ class BigPlayButton extends Button { | |||
/** | |||
* Handles click for play | |||
* | |||
* @method handleClick | |||
* @return {undefined} | |||
* n/a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced we should have an @return
tag for functions that don't explicitly return anything (i.e. undefined
). That seems like a feature of the language rather than something we need to document.
* The class name or instance of a child to add | ||
* | ||
* @param {Object} [options={}] | ||
* including options to be passed to children of the child. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we lose "Options, " here?
* @return {Element} | ||
* @method createEl | ||
* the element that was created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this isn't implied by the fact that we have @return {Element}
... maybe. I'm torn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it may be implied but I don't think its a bad thing to document
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization, though. 😄
@@ -110,8 +127,8 @@ class ClickableComponent extends Component { | |||
/** | |||
* Allows sub components to stack CSS class names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make much sense. It's like it's describing why the method exists - not what it does. I think something like: "Constructs a string to be used for the component's element's className
." would be preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a why isn't necessary bad, though, it should be done in a secondary paragraph or something. The first thing should definitely be what it does.
* @return {String} | ||
* @method buildCSSClass | ||
* @return {string} | ||
* The current css class for this ClickableComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't feel particularly accurate. It returns the default className
for the component's element - not the current className
. I think we should avoid using the term "css class" because it's got nothing to do with CSS.
*/ | ||
setTimeout(fn, timeout) { | ||
fn = Fn.bind(this, fn); | ||
|
||
// window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't. | ||
// window.setTimeout would be preferable here, | ||
// but due to some bizarre issue with Sinon and/or Phantomjs, we can't. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is relevant anymore.
*/ | ||
static getComponent(name) { | ||
if (Component.components_ && Component.components_[name]) { | ||
return Component.components_[name]; | ||
} | ||
|
||
// TODO: deprecated? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the question here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to warn in the log that this is deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably something that should just be disallowed/removed in 6.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I will add an @deprication tag to the function here
@@ -49,6 +49,11 @@ class ErrorDisplay extends ModalDialog { | |||
} | |||
} | |||
|
|||
/** | |||
* Available options for an error display |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be "Default options" instead of "Available options".
*/ | ||
import * as Events from './utils/events.js'; | ||
|
||
/** | ||
* An EventTarget class that seeks to emulate much of the builtin | ||
* HTML EventTarget functionalify as well as add all kinds of ease |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "functionalify" and I think the sentence can end there. The rest is kind of vague.
EventTarget.prototype.allowedEvents_ = {}; | ||
|
||
/** | ||
* This function is a cross browser wrapper around addEventListener | ||
* with a much nicer syntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to describe what this does rather than its implementation, the same way the off
method does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff.
constructor(player, options) { | ||
super(player, options); | ||
this.controlText(options && options.controlText || this.localize('Close')); | ||
} | ||
|
||
/** | ||
* Constructs a string to be used for the component elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does jsdoc not provide any functionality for inheritance? So we would only need to document these in Component and then everything would be linked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anything that you override needs to be documented, we get anything that is not overridden, in the docs for the object. There are ways to say that this method should use the parents doc comments, but doing so causes jsdoc to link to the parent function rather than the current files function (so it seems like the current file does not implement it)
* @param {Event|Object|string} event | ||
* A string (the type) or an event object with a type attribute | ||
* | ||
* @param {Object} [hash] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there an "optional" indicator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brackets []
around the parameter indicate optional
* 'width' or 'height' | ||
* | ||
* @return {number|boolean} | ||
8 the dimention or false if nothing was set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8 instead of *.
dimension mispelled.
This doesn't return a boolean. It should default to 0
, I believe.
*/ | ||
static getComponent(name) { | ||
if (Component.components_ && Component.components_[name]) { | ||
return Component.components_[name]; | ||
} | ||
|
||
// TODO: deprecated? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably something that should just be disallowed/removed in 6.0
@@ -27,11 +30,10 @@ class ErrorDisplay extends ModalDialog { | |||
/** | |||
* Include the old class for backward-compatibility. | |||
* | |||
* This can be removed in 6.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what this refers to specifically.
@gkatsev @misteroneill ready for re-review |
As a general comment, I think it'd be good to have some kind of conventions regarding grammar. My personal feeling is that things should generally follow English grammar. So, something like this:
But that's me. If more people disagree, that's fine. Thoughts? |
sounds good to me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started adding individual line comments, but I think the whole thing could use a grammar sweep. Unless someone disagrees, I believe documentation should follow the conventions of the language in which it's written.
* @return {String} The constructed class name | ||
* @method buildCSSClass | ||
* @return {string} | ||
* returns default class name ie. 'vjs-big-play-button' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple grammatical updates here: Returns default class name, i.e., 'vjs-big-play-button'.
constructor(player, options) { | ||
super(player, options); | ||
} | ||
|
||
/** | ||
* Allow sub components to stack CSS class names | ||
* Get the default css class for the BigPlayButton |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're leaving "css" here it should be capitalized.
* | ||
* @param {Object} [options] | ||
* Object of option names and values | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both "constructor" and "the" should be capitalized in this block.
* Constructor for Button | ||
* | ||
* @param {Player} player | ||
* the player to attach this button to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization.
* | ||
* @method handleKeyPress | ||
* @param {Event} event | ||
* the button event that caused this function to be called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization.
* @return {Element} | ||
* @method controlText | ||
* the control text element | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably stand to have some capitalization added to both the @return
and the description above.
* | ||
* @return {string|ClickableComponent} | ||
* - The control text when getting | ||
* - Returns itself when setting; method can be chained. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this get Markdown-ified?
* @return {String} | ||
* @method buildCSSClass | ||
* @return {string} | ||
* the default className for a component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization and sentences should end in periods.
* @method handleKeyPress | ||
* @param {Event} event | ||
* the event that caused this to be called, in most cases | ||
* this will be the `keydown` event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave out everything after the comma. And capitalize.
* var button = player.addChild('button'); | ||
* | ||
* console.log(button.el()); | ||
* // will have the same html result as the previous example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should really have code examples in API docs or leave that to the manual documentation/guides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A part of me feels like we need to have doc comments that link to guides, and the guides should be the ones with the examples. Maybe another PR to rip examples out into manual documentation at a later date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an upside to have examples here:
- more likely to get updated if things change
- A user doesn't have to go to a guide to read up on how to use it
But I'm ok with moving it to a guide and linking it here in a separate PR pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another benefit of having the jsdoc
comments not contain examples. Is that we can lint markdown examples with eslint. Which cannot be done with jsdoc markdown examples.
* This gets called when a `ClickableComponent` gets: | ||
* - Clicked (via the `click` event, listening starts in the constructor) | ||
* - Tapped (via the `tap` event, listening starts in the constructor) | ||
* - Gains focus (via the `focus` event). Causes `ClickableComponent` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't listen to keydown
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When focus
is triggered handleFocus
is called.
* This gets called when a `CloseButton` gets: | ||
* - Clicked (via the `click` event, listening starts in the constructor) | ||
* - Tapped (via the `tap` event, listening starts in the constructor) | ||
* - Gains focus (via the `focus` event). Causes `ClickableComponent` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
* var button = player.addChild('button'); | ||
* | ||
* console.log(button.el()); | ||
* // will have the same html result as the previous example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an upside to have examples here:
- more likely to get updated if things change
- A user doesn't have to go to a guide to read up on how to use it
But I'm ok with moving it to a guide and linking it here in a separate PR pass
* Whenever a property is an object on both options objects | ||
* the two properties will be merged using mergeOptions. | ||
* Deep merge of options objects with new options. | ||
* > Note: When a property of is an object on both `obj` and `options`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"When a property of is an object" is weird.
Maybe something like:
When both obj
and options
contain a property whose value is an object, the two properties get merged using mergeOptions
* - `otherComponent.on('eventName', myFunc)` | ||
* Is that the listeners will get cleaned up when either component gets disposed. | ||
* It will also bind `myComponent` as the context of `myFunc`. | ||
* > **NOTE**: If you remove the element from the DOM that has used `on` you need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think usage of NOTE
is consistent.
@@ -1378,12 +1711,16 @@ class Component { | |||
} | |||
|
|||
/** | |||
* Registers a component | |||
* Register a `Component` with `videojs` given the name and the component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a note that Techs shouldn't be registered as Components?
* | ||
* @typedef {Object} EventTarget~Event | ||
* @see [Properties]{@link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line, please
* | ||
* @param {Object} [hash] | ||
* hash of data sent during the event | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line, please
*/ | ||
/** | ||
* An object containing event names as keys and true/false values as values. If an | ||
* event name is set to a true value here {@link EventTarget#trigger} will have extra. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is incomplete. What will trigger
have extra of?
* | ||
* If the name of the Event that is being triggered is in `EventTarget.allowedEvents_` | ||
* then trigger will also call the `on` + `uppercaseEventName` function. Example: | ||
* the 'click' is in in `EventTarget.allowedEvents_` trigger will attempt to call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
click
is inallowedEvents_
, so, trigger will attempt to callonclick
if it exists.
added docs where missing updated examples where broken or where they did not make sense eslinted with eslint-plugin-jsdoc change @link to @see better @return descriptions for chainable methods ran hemmingway over the jsdoc comments custom event type custom callback types better @Listens, @fires, and @event documentation
made jsdoc recursive
Description
@return
and description where missing from functions@param
and description where missing@class
and@method
@events
and@fires
Requirements Checklist