Patch that adds JSDoc to all modules not covered in #2493683: JSDoc for JS using Backbone.

Added @file to all files.
Wrapped comment lines to 80 char.
Almost all first line comments are actually on one line.
Added JSDoc for all "public" function (but not all descriptions). Some function local function not present in the global scope don't have complete jsdoc yet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, core-jsdoc-modules.patch, failed testing.

Status: Needs work » Needs review

jhodgdon queued core-jsdoc-modules.patch for re-testing.

nod_’s picture

Status: Needs review » Postponed
Related issues: +#2493683: JSDoc for JS using Backbone
FileSize
181.34 KB
279.47 KB

I ended up putting all the modules here, including the ones in #2493683: JSDoc for JS using Backbone because it's a pain to do the diff. If anyone has some git-fu and has an easy way to exclude 4 folders from a diff, let me know.

nod_’s picture

Status: Postponed » Needs review
FileSize
108.68 KB
15.11 KB

Well, that worked. git diff 8.0.x..jsdoc-modules -- core/modules/ ":(exclude)core/modules/quickedit" ":(exclude)core/modules/toolbar" ":(exclude)core/modules/editor" ":(exclude)core/modules/ckeditor"

Ignore previous comment.

nod_’s picture

FileSize
108.75 KB
1.08 KB

Adding more type info.

nod_’s picture

FileSize
108.75 KB

Reroll

nod_’s picture

nod_’s picture

FileSize
3.53 KB
108.68 KB

@link stuff.

nod_’s picture

FileSize
805 bytes
109.5 KB

Reroll adding the new file from #2429443: Date format form is unusable.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

You know, this patch does not do any harm, but rather make it actually possible to be parsed by jsdoc.
I mean you could iterate on the patch level, but I think it would be way more sane to iterate for such tasks on a per issue level.

If people agree with that, I think we should RTBC the other 2 ones as well.

  1. +++ b/core/modules/block/js/block.js
    @@ -55,8 +64,8 @@
    -      var tableDrag = Drupal.tableDrag.blocks; // Get the blocks tableDrag object.
    -
    +      // Get the blocks tableDrag object.
    +      var tableDrag = Drupal.tableDrag.blocks;
           // Add a handler for when a row is swapped, update empty regions.
    

    I'm curious, is there something like inline type comments like /** @var \Drupal... $foo in PHP

  2. +++ b/core/modules/filter/filter.filter_html.admin.js
    @@ -37,6 +44,12 @@
    +   *
    +   * @todo Remove everything but 'attach' and 'detach' and make a proper object.
    +   */
    

    Do we have an issue for that todo?

eiriksm’s picture

You beat me to it :)

I was also looking through this now, and although I am not done looking, I agree with the view presented by @dawehner.

Also:

I'm curious, is there something like inline type comments like /** @var \Drupal... $foo in PHP

You can do stuff like /** @property {string} selector */ inline. Not sure how the output would be for Drupal jsDoc setup, but as a worst case, one can do it on several lines:

/**
  * @property {string} selector
  *   A selector.
  */
  var selector = '#some-long-id';

In theory. One would have to agree on a standard, though.

I'll look through the rest of the patch too, but looking good so far.

jhodgdon’s picture

Thanks! Yes that's the approach we agreed to on the meta-issue. So the review on this and the other two should be something like "Is there anything blatantly wrong in this and can we verify it just adds/updates comments and not code". Thanks you two for doing this one!

eiriksm’s picture

Status: Reviewed & tested by the community » Needs work

OK, so that patch was quite the marathon. Did not check each and every variable and return value if it was actually the correct type, but as dawehner say, this is such a great start anyway.

A couple of things. Some very minor.

  1. +++ b/core/modules/contextual/js/toolbar/views/AuralView.js
    @@ -7,16 +7,23 @@
    +     * Tracks whether the tabbing constraint announcement has been read once yet.
    

    Juuust 1 character too much :p

  2. +++ b/core/modules/contextual/js/toolbar/views/VisualView.js
    @@ -30,7 +28,13 @@
    +     * Renders the visual view of the edit mode toggle. Listens to mouse & touch.
    

    81 characters :p

  3. +++ b/core/modules/file/file.js
    @@ -124,14 +139,24 @@
    +     * @name Drupal.file.triggetUploadButton
    

    Typo. Should be triggeR not triggeT

  4. +++ b/core/modules/locale/locale.admin.js
    @@ -73,10 +82,20 @@
    +    /**
    +     *
    +     * @return {string}
    +     */
    

    I see you have a lot of these. Is the extra new line before the @return to make room for other things?

  5. +++ b/core/modules/tour/js/tour.js
    @@ -148,22 +197,21 @@
    +     * @example <caption>This will filter out tips that do not have a matching
    +     * page element or don't have the "bar" class.</caption>
    +     * http://example.com/foo?tips=bar
    

    Earlier in this file you had @example followed by a new line. Should be the norm IMO

  6. +++ b/core/modules/tour/js/tour.js
    @@ -148,22 +197,21 @@
    +     * @see Drupal.tour.views.ToggleTourView#_getDocument()
    

    Should be something like @see {@link Drupal.tour.views.ToggleTourView#_getDocument} IMO. Just since we can. Although of course in this case, the link is like 250px above this one, but as a norm, I think we should use @link where possible.

  7. +++ b/core/modules/views_ui/js/views-admin.js
    @@ -410,9 +525,10 @@
    +      // If the display has no contextual filters, hide the form where you
    +      // enter
    +      // the contextual filters for the live preview. If it has contextual
    +      // filters, show the form.
    

    Seems like a new line that stems from reformatting from 80 chars.

If no one bets me to it I'll upload an altered patch myself to make up for being the jerk that sets a RTBC issue to needs work ;)

eiriksm’s picture

Is there anything blatantly wrong in this and can we verify it just adds/updates comments and not code"

Hm, well there is nothing blatantly wrong I guess. And it does just add/update comments and not code. So please feel free to tell me if I am being too strict with setting to needs work here :)

nod_’s picture

Status: Needs work » Needs review
FileSize
109.49 KB
3.16 KB

#10.1 : we could do that as #11 said. This is an internal variable, no point in JS-Documenting it now.

#10.2 : Not yet.

#12 : fixed everything but 4. Extra line is from PHPStorm auto commenting stuff, won't fix that here.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Alright, let's ship it

eiriksm’s picture

awesome!

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Most of this looks great! Obviously will need some more stuff filled in, but overall it adds a lot.

Follow-ups (besides generally filling stuff in):
- core/modules/field_ui/field_ui.js -- a bit off in places with wrapping and indentation, especially in - lists
- core/modules/views_ui/js/views-admin.js

58 files changed, 1157 insertions(+), 316 deletions(-)

Wow. that's a lot of work. Committed to 8.0.x. Thanks!

  • jhodgdon committed c3cb303 on 8.0.x
    Issue #2493691 by nod_, eiriksm, dawehner: Add JSDoc for core modules JS
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.