Opened 11 years ago
Closed 11 years ago
#26870 closed task (blessed) (fixed)
Add (JSDoc)umentation to the Backbone-centric Media files
Reported by: | wonderboymusic | Owned by: | |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.5 |
Component: | Media | Keywords: | needs-patch needs-docs |
Focuses: | docs | Cc: |
Description
See: http://make.wordpress.org/core/2014/01/13/audio-video-2-0-codename-disco-fries/
This is a spike ticket for feedback and commits about JSDoc implementation inside the @koop Media code from 3.5
Attachments (5)
Change History (33)
#2
@
11 years ago
26870-media-models.diff adds initial JSDoc blocks for src/wp-includes/js/media-models.js
- this is a base to work from and iterate on
#3
@
11 years ago
26870-media-editor.diff add baseline docs to src/wp-includes/js/media-editor.js
- will need more iterations, but this gets us started.
#6
@
11 years ago
Was the first part of [26985] intended? Little bit clueless here. To me this is a code change and not documentation so I rather would have seen two commits to make it clear why it was done.
#7
@
11 years ago
There are several places where it is hard to disambiguate / add inline docs, due to missing {}
s around if/else
s - no longer
This ticket was mentioned in IRC in #wordpress-ui by joedolson. View the logs.
11 years ago
This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.
11 years ago
#19
@
11 years ago
While doing a bit of jshint work on media-views.js, I noticed:
/** * call 'validator' directly on wp.media.model.Selection */ && media.model.Selection.prototype.validator.apply( this, arguments );
@wonderboymusic, I am not sure it makes sense to document what is standard, albeit ugly, javascript. This particular case also breaks the jshint rules and makes the logical expression a bit harder to read, which is why it jumped out to me. If we feel like these statements are not clear, maybe we want to introduce a _super()
method. I have seen but not used the following approach for doing this, which we probably would want to add only at the wp.Backbone
or wp.media
level.
Backbone.Model.prototype._super = function(funcName){ return this.constructor.__super__[funcName].apply(this, _.rest(arguments)); };
#20
@
11 years ago
yeahhh... some of that is overzealous - so much of that code was a black hole when I started, the extra comments were more for my own comfort than anything else. Feel free to make whatever edits you feel are necessary - I just wanted to get the ball rolling so I understood how all of it worked.
#21
@
11 years ago
26870-media-views-02.patch removes the comments when calling super
via Function.prototype.apply
and adds a bit of context to the documentation for some of the base constructors.
26870-media-views.diff is a first pass at documenting
src/wp-includes/js/media-views.js
. It would be an understatement to say I almost blacked out several times chasing down all of the chains of inheritance. There is still more to document, but I think this could go in for a base to work from.Notes:
wp.media.controller.StateMachine
just for laughs. These classes are marked with@constructor
, and the classes in the inheritance chain are annotated with@augments
this
inside of instance methods with the@this
annotation. This is by far the most confusing aspect of a lot of the code.wp.media.controller.State
is basically an abstract class that many of these classes are intertwined with.wp.media.controller.Region
provides a lot of the black voodoo that triggers custom eventsAnyways - more to be done.