Problem/Motivation
The @param and @return documentation in displace.js committed in #1847084: Measure/track displacing elements better + provide change events for them (fix overlay + toolbar) does not follow the Doxygen format documented at http://drupal.org/node/1354.
http://drupal.org/node/1354#param
http://drupal.org/node/1354#return
JavaScript coding standards: http://drupal.org/node/172169
Brought up in #77 and discussed in a few comments afterwards:
#1847084-77: Measure/track displacing elements better + provide change events for them (fix overlay + toolbar)
Committed code:
+++ b/core/misc/displace.jsundefined
@@ -0,0 +1,179 @@
+ * @param {jQuery} $el
+ * The jQuery element whose dimensions and placement will be measured.
+ *
+ * @param {string} edge
+ * The name of the edge of the viewport that the element is associated
+ * with.
Proposed change:
+++ b/core/misc/displace.jsundefined
@@ -0,0 +1,179 @@
+ * @param jQuery $el
+ * The jQuery element whose dimensions and placement will be measured.
+ * @param string edge
+ * The name of the edge of the viewport that the element is associated
+ * with.
Proposed resolution
Remove curly braces from data types in docblocks, remove extra lines between each @param.
Remaining tasks
A patch needs to be created that makes these changes.
User interface changes
n/a
API changes
n/a
Related Issues
Comment | File | Size | Author |
---|---|---|---|
#35 | update-js-documentation-1958246-35.patch | 14.48 KB | rteijeiro |
#27 | update-js-documentation-1958246-27.patch | 13.28 KB | rteijeiro |
#23 | update-js-documentation-1958246-23.patch | 20.06 KB | rteijeiro |
#18 | update-js-documentation-1958246-18.patch | 20.09 KB | rteijeiro |
#16 | update-js-documentation-1958246-16.patch | 21.87 KB | rteijeiro |
Comments
Comment #1
star-szrAnother thing I'm curious about - is there a reason why $el has a dollar sign but edge doesn't?
Comment #1.0
star-szrAdd more 1354 citations
Comment #1.1
star-szrRemove unneeded word: "standard"
Comment #2
jessebeach CreditAttribution: jessebeach commentedThe '$' character in a variable name is a convention used to distinguish a jQuery set of DOM elements for a DOM element. It's a hint that jQuery methods an be used with this variable.
Comment #3
star-szrMakes sense, thanks! Is this documented anywhere?
Comment #4
nod_I think so, in case it's not it should be added in this issue: #1778828-7: [policy, no patch] Update JS coding standards
Comment #5
Wim LeersShould we also remove the curly braces from other JS in core? :)
Other locations: toolbar.module, contextual.module (a little bit), ckeditor.module (a tiny bit), dropbutton, matchmedia, drupal.js, displace.js, debounce.js.
Comment #6
nod_In the background of this issue we can find #1337022: [policy, no patch] Create/adopt JavaScript docs standards compatible with a JS documentation parser and #25901: Parse/save/display JavaScript files.
Comment #7
webchickRe: #5 ... Yes.
Comment #8
rteijeiro CreditAttribution: rteijeiro commentedI have created a patch with the js documentation cleaning of the files in core. I guess I didn't forget anyone.
Also I hope the patch is right (it's my first patch)
Feedback is welcome.
Comment #9
jessebeach CreditAttribution: jessebeach commentedrteijeiro thank you for the patch. It seems like you may have gotten more changes in your diff than just comments. Try rebasing your branch on the current 8.x branch, so that just the changes you made are present and not any changes from when you created your branch to the time that you created the diff. Does that makes sense?
Comment #11
rteijeiro CreditAttribution: rteijeiro commentedHi Jesse, sorry for the mistake. I fetched and rebased with 8.x branch. Hope the patch is now right. If not, just notify me again ;)
Comment #13
rteijeiro CreditAttribution: rteijeiro commentedSorry, this patch is crappy again. I will try to fix it.
Comment #14
rteijeiro CreditAttribution: rteijeiro commentedI guess now I did the diff with the correct branch :)
Comment #15
Wim LeersShould be uppercased.
Idem.
Idem.
(And several more of these. I checked with nod_ to make sure that's the goal.)
"Integer" does not exist in JavaScript. This should be "Number".
Comment #16
rteijeiro CreditAttribution: rteijeiro commentedAlso did the following changes:
- Uppercased 'string' to 'String'.
- Uppercased 'number' to 'Number'.
- Changed 'bool' by 'Boolean'.
Comment #17
Wim LeersAwesome! I wanted to RTBC, but there's just one more thing…
We shouldn't be changing external libraries.
Comment #18
rteijeiro CreditAttribution: rteijeiro commentedIt's true. I didn't realized about that :)
Fixed.
Comment #19
Wim LeersAwesome, thanks! :)
Comment #20
rteijeiro CreditAttribution: rteijeiro commentedGreat!! My first patch ^_^
Thanks, guys!!
Comment #21
jessebeach CreditAttribution: jessebeach commentedLooks great, thank you so much rteijeiro!!!!
Comment #22
alexpottNeeds a re-roll
Comment #23
rteijeiro CreditAttribution: rteijeiro commentedRerolled.
Please, tell me if everything is ok.
Comment #24
star-szr#23: update-js-documentation-1958246-23.patch queued for re-testing.
Comment #26
star-szrNeeds another reroll…
Comment #27
rteijeiro CreditAttribution: rteijeiro commentedRerolled with the latest changes in 8.x branch.
Comment #29
rteijeiro CreditAttribution: rteijeiro commented#27: update-js-documentation-1958246-27.patch queued for re-testing.
Comment #31
star-szr#27: update-js-documentation-1958246-27.patch queued for re-testing.
Comment #33
rteijeiro CreditAttribution: rteijeiro commented#27: update-js-documentation-1958246-27.patch queued for re-testing.
Comment #34
star-szrI just reviewed the patch and did some grepping and this looks quite good to me.
find core ! -path */external/* ! -name jquery.js -type f -name *.js -exec grep -nH " \* @.*{.*}" {} \; | grep -v inheritdoc
I found a few curly braces in ckeditor.admin.js that can be cleaned up:
And one in tableheader.js:
Comment #35
rteijeiro CreditAttribution: rteijeiro commentedGreat command, @Cottser, thanks!
Updated the patch according the #34 comment.
Comment #36
rteijeiro CreditAttribution: rteijeiro commentedForgot needs review status :(
Comment #37
cilefen CreditAttribution: cilefen commentedA grep through all the core js shows all curly braces are accounted for by update-js-documentation-1958246-35.patch in comment #35.
Comment #38
star-szrI think this is RTBC once it comes back green, quite a queue right now though.
Comment #40
rteijeiro CreditAttribution: rteijeiro commented#35: update-js-documentation-1958246-35.patch queued for re-testing.
Comment #41
star-szrGreat work @rteijeiro :)
Comment #42
rteijeiro CreditAttribution: rteijeiro commentedThanks Cottser :)
Hope it will be merged before someone changes one of those files :P
Comment #43
nod_This patch makes jsdoc useless btw. Not sure how important that is but it's too bad.
Comment #44
rteijeiro CreditAttribution: rteijeiro commentedWhat abou this? #1337022: [policy, no patch] Create/adopt JavaScript docs standards compatible with a JS documentation parser
Comment #45
nod_yeah don't get me started on that one.
The thing is that with the default jsdoc template, without the
{}
it will think the type is actually the name of the variable and we end up with documentation likeannonce(String, String)
instead ofannonce(text, priority)
.Also if we want to rely on a documentation tool and not having to write our own, we have to go with JSDoc. If it's good enough for google, it's good enough for us: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?sh...
If someone wants to write a doxygen parser for JS sure, we can go with that. Won't be me though and I'd like JS docs in the near future, either as jsdoc output or on api.d.o, whichever comes first.
Comment #46
webchickSounds like this needs more discussion?
Comment #47
cilefen CreditAttribution: cilefen commentedDefinitely. If Doxygen isn't an option for javascript it probably doesn't make sense to comment in its style.
If that is true about Doxygen then we'd be better off going with the best available JS documenter and writing a Drupal standards filter for it if necessary.
One of the key questions is whether we could integrate its output with the PHP file documentation.
Comment #48
nod_@cilefen that has been worked on by attiks: #1337022-80: [policy, no patch] Create/adopt JavaScript docs standards compatible with a JS documentation parser and his proof of concept is still online: http://drupalapi.attiks.com/api/js-samples/files/7 since JS is so different than PHP there are a few concepts that can't be properly handled by the api module.
Comment #48.0
nod_Add link to JS coding standards
Comment #49
parthipanramesh CreditAttribution: parthipanramesh commentedpatch failes..
Comment #50
nod_About this issue: No.
Patch to come in another issue. I'll link to it once patch is up.