Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Patch that adds JSDoc to all misc/ files.
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.
Comment | File | Size | Author |
---|---|---|---|
#18 | core-jsdoc-misc-2493677-17.patch | 152.73 KB | nod_ |
#18 | interdiff.txt | 484 bytes | nod_ |
Comments
Comment #1
nod_Comment #2
nod_Expose some internal stuff about tabbing manager script.
Comment #3
nod_Reroll
Comment #4
Wim LeersSuch an enormous undertaking. My hat off to you, @nod_.
This is ready AFAICT. But the thing that it most needs, is feedback from a core committer, and likely from @jhodgdon. So, assigning to her.
Comment #7
nod_Still applies, testbot madness.
Comment #8
jhodgdonWell, I took a look...
I'm not excited about committing this patch. It adds a lot of @param and @return lines with zero descriptive docs. I would really prefer to leave out the @param/@return entirely until we have descriptions, because having lines like this will encourage more of them to be done like this, and it's incomplete docs. I'm assuming that the same standards apply to JS docs as we have for PHP docs, that @param and @return require descriptions?
Some other comments:
I took a look at the docs for the ~ and I still don't get this. Where is Drupal~behavior defined? I cannot find it anywhere.
Nitpick: should be "... all created objects" although this was in the original incorrect as well, so possibly out of scope to fix here.
You might add a big note on https://www.drupal.org/node/2183405 about this.
In PHP docs, anything that can be turned into a link will be turned into a link automatically.
It appears that in JSDoc, this is not true, and also the syntax of @link is quite different from the PHP docs we use in Drupal. So... I think if this is not true in JSDoc we probably need to have a standard that *everything* is made into links manually, which will be tedious. But otherwise it's hard to find what is being referred to.
In the JSDoc standards doc it says to use "array" not "Array"?
https://www.drupal.org/node/2183405
I'm a bit confused about this. It's a variable, so why is it's description starting with a verb as if it's a function that does something, rather than a variable that has a value?
Shouldn't all of these properties have documentation, and shouldn't their docs ideally be just before they're defined below rather than in the ajax.options doc block?
Shouldn't all @param lines have documentation about what the parameters are? The problem with committing this with partial docs is that people will start copy/pasting it. I would almost prefer to have nothing rather than setting a precident of having @param without docs of what it is.
These parameters do not actually exist... they are properties of the response object parameter. Will this really work? We wouldn't document them like this in PHP at all. We'd document @param $response and then in the description have a list of what the properties are.
This tells me almost nothing, illustrating my inclination that adding @return or @param without docs is not a great idea.
So.. I ran out of time here... I'm not saying we should definitely not commit this patch, but I don't think it comes close to "this patch at least complies with our standards". I am only in favor of adding docs that are correct and are decent illustrations of how we should do docs. I'd rather not have docs than have docs that are bad examples... are they ever going to get fixed up? What's the plan here?
Comment #9
nod_It's not like our current docs are anywhere near complete, we have params with no description right now.
1. After applying the page: drupal.js line 135 or on the Drupal namespace doc page.
2. indeed, not on me that one, but fixed.
3. Well, we're not parsing our JS with our PHP tools so some things have to be different. This won't be more tedious than rolling this patch. Actually, I just did it, not that big a deal.
4. It now says
Array
5. fixed.
6. So ajax.options is a variable and in that case, JSDoc will not aggregate the docs of child elements, to do that we would need to declare ajax.options as a namespace and it'd be wrong. We're stuck with that, it's how object structure can be described in a way that makes sense here.
7. This patch won't set a precedent, it's already the case in the codebase. And as I mentioned in the meta, we'll have eslint to make sure everything gets described.
8. it works: http://read.theodoreb.net/drupal-jsapi/Drupal.Ajax.html#getEffect having an html list to describe what is in an object is a less good alternative compared to this. This describes parameters in a way an IDE can understand (and help).
9. I'd say "almost nothing > nothing". As said before this is no precedent, it's already like this in our JS comments.
I replied on the plan in the meta.
Comment #10
nod_Straight reroll because of #2489826: tabledrag is broken, no interdiff.
Comment #11
nod_Had some whitespace issues. all fixed.
Comment #12
nod_All right, the real whitespace fixing patch.
Comment #14
dawehnerI like this high level overview
Nice that this is possible!
Cool stuff!
Oh I see its defined somewhere else in that patch.
in remove ajax seems to still be used?
I'd had expected that you can use just "//" for those cases? My naive thinking is that "//" is always ignored
I was confused by the type used here, but well indeed, this seems to be the case, its the result of a $.get() call, so everything is fine.
I guess its not worth to add its own type here?
Those bits are a bit odd. Won't it be helpful to have that part of the documentation?
In other bits of the code we seemed to have used ?HTMLElement to make things optional. I guess both things are possible?
Comment #15
nod_Comment #16
nod_1..4 thanks!
5. Technically it's optional since we fall back to drupalSettings if neither settings are set. It's optional in the sense that if it's empty, it won't break.
6. You're right in that // are ignored but for some reasons JSDoc picks those strings up and add them to the documentation. Just ignored those to make things easier (ideally we wouldn't have any @ignore tag).
8. Creating a type just makes the documentation a click away, here it's more explicit.
9. Autoformat fail. Fixed.
10. Indeed, fixed.
Thanks for the review!
Comment #17
dawehnerAlright
Comment #18
nod_Reroll for #2472177: Collapsible fieldset have duplicated and wrong aria-expanded
Comment #19
nod_Comment #20
jhodgdonLooks good enough! Committed to 8.0.x. Whew! That's the last of the big ones. ;) Thanks nod_ and reviewers!
Followups/questions:
a)
I'm not sure exactly what these lines do with @lends (but they're common in all 3 patches) - minor suggestion, I think they'd be easier to scan/read by humans if there was a space between the */ and the {
Thoughts?
b)
Also don't use JS in docs, write out JavaScript:
c) In drupal.js, there are a number of doc blocks that don't seem to have any code after them. Is that right? Seems like the docs should go near the code they're documenting?
Comment #22
nod_a) if we add a space then eslint complains about the extra space. We could avoid having to use @lends but it requires a pretty big refactor.
b) woops, will fix in the drupal.js doc issue.
c) For those there isn't really a good place to put them. It's a bit like what's in *.api.php files. Might be good to put those in a separate file that will only get picked up by jsdoc actually.
Thanks again for getting that in despite it's issues!
Comment #23
jhodgdonCool. Let's just proceed as you have been doing it then. If there's a good reason, there's a good reason. ;)