Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Jun 2015 at 17:42 UTC
Updated:
12 Sep 2015 at 06:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
eiriksmThis was a small one, documentation wise. JS file should also be moved into the js folder, but that is taken care of in #2484623: Move all JS in modules to a js/ folder.
For the record. Looking through the javascript, and then trying to figure out what pages it was run on also spawned #2504711: Summaries are not added for collapsible fieldsets if the browser supports "details"
Comment #2
eiriksm...and forgot needs review.
Comment #3
nod_Brilliant.
Comment #4
jhodgdonHm. So I've now made this comment on 2 other patches...
I've noticed that Drupal~behavior items have attach: functions in them. The lines look like this:
So it looks to me like this is a function called Drupal.behaviors.bookDetailsSummaries.attach right? If so, shouldn't it (and all the similar ones) have docs for the attach() function (which maybe is just an @inheritdoc)?
The rest of this patch looks good!
Comment #5
nod_I defined the Drupal~behavior type to avoid copy pasting. Basically tagging something as
Drupal~behaviormeans the thing is an object with an attach and detach property. Both properties are functions with their own parameters.I don't feel it's needed to document both because detach should be undoing whatever attach function does (in reality it's the case when a detach function exist) and only that so describing what is done in attach is sufficient. If we where to document both function individually we would need to do :
One downside of this form is that we would need to always document
context,settingsandtriggerparameters because we can't use @inherit since there is no Constructor/Class involved with behaviors (nothing to inherit from in the sense of javacript objects). And if we were to use something like @borrows (which didn't work when i tried, don't know if jsdoc bug or me), we would lose the ability to describe individual settings keys needed in the settings object like it's done in the proposed patch #1835016-38: Polyfill date input type.The downside of using Drupal~behavior is that we can't document what's in settings for attach function like it's done in the issue above.
Comment #6
jhodgdonSo our PHP docs standards basically say "Everything needs a doc block". Do you think that should not be the case here? I mean, it's a member function, so it seems like it should have docs of some sort, and also isn't it the case that a function without JSDocs does not show up on the JSDoc output site?
Comment #7
nod_I'm worried about people being too lazy to document all the parameters properly and having rubbish docs in their projects. Adding just one @type tag to the behavior seems easier.
The page with the list of behaviors is easy to follow: http://read.theodoreb.net/drupal-jsapi/Drupal.behaviors.html we know what's there and the description is easy to access. For the type information clicking on the type beside the name redirect to http://read.theodoreb.net/drupal-jsapi/Drupal.html#~behavior which will show attach/detach and all the types and params available.
I tried several things to make it easy on people to document this but unfortunately there is nothing we can bend to have an @inheritdoc type of thing. This is due to the way our code is architected and I didn't find a way to make it easier. Also if we document attach/detach, unless the parent object is declared as @namespace, anything written in the docblocks will not show up in the docs.
I'll let you choose what you prefer between the 3 possibilities. For me:
1. is the easiest,
2. is the most explicit and readable (talking about the doc output), it would be my pick,
3. is the most correct but error prone.
Comment #8
jhodgdonThanks for the explanation. I'm OK with any of those options you presented.
How about if you pick one of your choice and update the JS docs standards page to explain when this type of documentation should be used instead of the usual "everything needs documentation" rul?
Comment #9
nod_All right, number #2 it is, will make is easy to spot behavior with no detach function (a todo to solve in core at some point).
Thanks! I'll get the doc updated.
Comment #10
nod_Updated: https://www.drupal.org/node/2183405#behavior
Comment #11
eiriksmOK, here is an updated patch with the attach function also added to the doc block. Thanks for taking the time to clarify this, and updating the docs!
Comment #12
nod_Standard was decided and patch updated accordingly (and all the JSDoc patches in the queue were updated by eiriksm too).
Comment #13
webchickCommitted and pushed to 8.0.x. Thanks!