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.
Problem/Motivation
Part of meta-issue #1310084: [meta] API documentation cleanup sprint
Proposed resolution
Correct the following in the core user module:
- Ensure that all
@return
lines are preceded by a blank line. - Ensure that
@see
and@ingroup
lines are always at the end of docblocks. - Ensure that all lines in doxygen blocks are 80 characters or fewer (excluding the terminal newline).
- Ensure that all functions, classes, interfaces, and methods have one-line summaries that are clear, use the correct verb tense, and follow specific standards in http://drupal.org/node/1354.
- Make incidental style and grammar corrections only to those docblocks already being updated.
Remaining tasks
Patch needs to be rolled.
User interface changes
None.
API changes
None.
Follow-up issues
Comment | File | Size | Author |
---|---|---|---|
#67 | 1326666.patch | 905 bytes | grendzy |
#62 | 1326666-62-user-doc-cleanup.patch | 70.37 KB | Cameron Tod |
#62 | interdiff.txt | 1.46 KB | Cameron Tod |
#60 | 1326666-59-user-doc-cleanup.patch | 69.53 KB | Cameron Tod |
#60 | interdiff.txt | 18.74 KB | Cameron Tod |
Comments
Comment #1
jhodgdonDo you plan to patch this module? If so can you assign the issue to yourself and also add your name to the summary issue? Thanks!
Comment #2
synth3tk CreditAttribution: synth3tk commentedLars, are you still planning on patching this module?
Comment #3
Lars Toomre CreditAttribution: Lars Toomre commentedNope... Just set up the task item.
Comment #4
Cameron Tod CreditAttribution: Cameron Tod commentedI will look at doing this. I will update the meta issue.
Comment #5
Cameron Tod CreditAttribution: Cameron Tod commentedOk, here's a patch. Lot's of docblock reformatting to fit within 80 characters and to add line breaks after one sentence summaries. Several functions had no docblock at all, and I have put in one line summaries using the style guide at http://drupal.org/node/1354.
Several functions do not have parameter or return definitions, I will create issues for these.
Comment #6
Kars-T CreditAttribution: Kars-T commentedSeems basically great but there are some unneeded spaces after line end. I found no typos and the comments made sense but I am no native speaker. Please remove the unneeded spaces and I'd say it's RTBC.
Comment #7
Cameron Tod CreditAttribution: Cameron Tod commentedGreat, will do.
Comment #8
jhodgdonRegarding the functions without param/return - probably the best thing would be to file 1 issue with title "Several functions in user.module lack param/return documentation" and then list them, so we can have one patch rather than a bunch. Thanks!
Regarding the patch in #5 --
a) forms -- at least one doc line you put in is not quite according to our standards:
http://drupal.org/node/1354#forms
Should just say "Form validation hanlder for user_admin_account()." (assuming that is the correct name for the form function).
Also, this is not up to standards:
b)
You can leave the "boolean" there... actually it should be "bool". See http://drupal.org/node/1354#functions (scroll down to the Data Types on param/return section)
c)
First line descriptions must be cut down to 80 characters or less. Also they should start with a verb in the right tense. See
http://drupal.org/node/1354#functions
This occurs in a couple of other places in the patch. Please check the files and make sure all functions conform to the standards, and fix any that don't.
d) typo (contructor):
+ * Form conctructor for the user login block.
Comment #9
Cameron Tod CreditAttribution: Cameron Tod commentedThanks jhodgdon. Will do.
Comment #10
Cameron Tod CreditAttribution: Cameron Tod commentedA lot more cleaning up. I've posted a couple more tasks for follow up:
#1419796: Make sure that all form constructors, validators, and submit functions have appropriate @see declarations
#1419792: Move all @ingroup declarations to be at the bottom of docblocks (under all @see declarations)
There's also quite a range of verb tense inconsistencies throughout the module, but altering them all is outside the scope of this sprint I think.
Comment #11
jhodgdonThose two separate cleanup issues you filed should be addressed here on this issue instead, as they are part of the Meta Cleanup task list. Please close those issues as duplicates and include them in this patch. Thanks!
Also, when you make links to other issues on drupal.org, if you type in [#(issue number)], it will turn into a nicer link that shows the issue status and issue title. :)
Comment #12
jhodgdonVerb tenses *are* within the scope of this sprint too. Take a look at the issue summary for this issue. :)
Comment #13
Cameron Tod CreditAttribution: Cameron Tod commentedYes I re-read it after you posted your last reply, and took a deep breath. I'm going to look at finishing this up this week. :)
Comment #14
Cameron Tod CreditAttribution: Cameron Tod commentedOk, changes made as described above.
Comment #16
Cameron Tod CreditAttribution: Cameron Tod commentedOk, looks like I have to learn how to rebase...
Comment #17
Cameron Tod CreditAttribution: Cameron Tod commentedRebased.
Comment #18
xjmPer #1315992: No standard for documenting menu callbacks, I think this needs @param, @return, and an @see to the hook_menu() implementation.
I think this one needs @see to its bretheren (other validation and submission handlers for the form).
I think there's usually a blank line between between the @todo and any @see/@ingroup, though I'm not positive. (http://drupal.org/node/1354 does not specify.)
Let's reword this so it's less than one 80-character line. Also, I think we need to change the semicolon to a colon, plus add the @param, @return, and @see (As described above).
If this is a menu callback, can we retain the prefix (but add a colon) and reword the rest to fit in 80 chars?I just looked and it's not a menu callback, so disregard. Your change is correct.Per the standard (http://drupal.org/node/1354#menu-callback), I think it should be:
Menu callback: Cancel....
Also, the @param/@return/@see.
Let's also reword this so that it's less than 80 chars.
Thanks @cam8001!
Comment #19
jhodgdontagging
Comment #20
adnasa CreditAttribution: adnasa commentedman, you guys are so quick on fixing things o_O
keep it up!
Comment #21
Cameron Tod CreditAttribution: Cameron Tod commentedIncorporating suggestions from #18.
I looked in a few other core modules, and it seems that @todo declarations are generally preceded by a blank line, so I've amended the docblock for user_load_multiple() to that standard. I read with interest #1315992: No standard for documenting menu callbacks :)
Comment #22
xjmFound more stuff!
I was going to say that it would be good to have a list of allowed values here... but looking at user_admin(), it's a bit... odd. Maybe a more detailed explaination? I'm also almost tempted to open a followup issue to un-!@#$ this function... maybe after the user entity class conversion.
Little awkward; maybe "Form constructor for a form to add or reorder user roles"? I'm not 100% sure though.
I'd say "Form
submission handlerconstructor for the role configuration form." EDIT: constructor, not submission handler. (Assuming this is a constructor and not a submission handler; I should have quoted more lines!)In these we can omit the "Required." The "optional" should be formatted thus:
- keyname: (optional) The foody bar baz thing.
(Reference: http://drupal.org/node/1354#lists)Trailing whitespace here.
Should be: "Loads the user object and performs standard login tasks."
I'd specify here that it's a confirmation form, perhaps:
Form constructor for the multiple user account cancellation confirmation form.
Should be: "Form submission handler for..."
I think the indentation here was correct before the change?
I think this should start with the summary:
Form submission handler for field_ui_field_edit_form().
I'd say "JSON-formatted string."
"one-time" should be hyphenated. Also, I think it would be better to say: "Processes a one-time login link..."
Let's make "timezone" one word here.
This whole section at the end of the patch is from a different commit... be sure to rebase before rolling your patch. ;)
Also, in general, adding parameter datatypes is not part of this cleanup sprint, but since what you've added is for new parameter documentation for the menu callbacks, which are fairly self-evident, I think it's okay.
Thanks!
Comment #23
Cameron Tod CreditAttribution: Cameron Tod commentedThanks for the feedback xjm, I'll clean things up!
Comment #24
Cameron Tod CreditAttribution: Cameron Tod commentedI must apologise for the lag here, I was away for the weekend and have since been very unwell with a super-cold. Not forgotten! Will look at this week.
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedSince there hasn't been activity for 4+ weeks, I'm going to move this back to unassigned.
Comment #26
vaidik CreditAttribution: vaidik commentedSubmitting the patch after working on suggestions pointed out in #22. Please review.
Comment #27
jhodgdonLooks pretty good! I think most of the items in review #22 are taken care of. A few details:
4.
This has to be rewrapped -- the word "menu" will fit on the previous line.
6.
Should not be $user, but just "user" without the $.
7.
That made the line go longer than 80 characters, so it needs some kind of a rewrite.
Other things I noticed:
a)
Take any lines like this you see out.
b)
This one-line description needs "the" or something in it to help it read better, and it should have an @see to the corresponding submission handler.
c)
First line should refer to user_filter_form() not _submit().
d)
This needs documentation of the $rid parameter. Similarly, user_admin_role() needs param docs, and user_admin_role_delete_confirm().
e) user.api.php
This doesn't follow the standards at http://drupal.org/node/1354#hooks
And just below that in the same hook:
f)
+ * This hook is called after the content has been assembled in a structured
+ * array and may be used for doing processing which requires that the complete
+ * user content structure has been built.
second line should be
array, and may be used for doing processing that requires...
[comma, which/that]
g)
This function is an override of a base class method, not an implementation of an interface method.
h) As in #6 above:
This should not be talking about $user but just "user" without the $. It would probably be good to check throughout the module for this and fix all of them. The only exception is if it's really referring to "global $user", such as here:
i)
I don't think this is really a formal form constructor... why doesn't it have $form_state as an argument if it is? Check that...
j)
use ID not id to refer to an identifier. The latter word "id" is a psychological concept.
k)
Needs "the" in that "Sets an error" sentence.
l)
Wow that bit about calling hook_user op 'login' is outdated! We haven't had hook_user() with ops since Drupal 6. It's now hook_user_login() and all function references should also have () after them.
m)
Needs "the" in first line "if the role was...".
n) Another "needs the" spot:
o)
First line needs to say what form is being altered. See 2nd example in:
http://drupal.org/node/1354#hookimpl
p) This is out of scope for API docs and should be removed from the patch:
q) Generally, even after this patch user.test is a mess. It needs to be cleaned up. It has such "lovely" "docs" as:
- No docblock on the classes at all, and many of the methods [but note that getInfo(), setUp() and tearDown() should not have doc blocks]
- wrong verb tenses
- This kind of a mess:
r) After looking at this file and seeing all the stuff in there that wasn't fixed in this patch, I am wondering if similar problems exist in the other files -- it would be good to look them all over when rolling the next patch, and make sure that all the functions are documented, and documented properly.
Comment #28
Cameron Tod CreditAttribution: Cameron Tod commentedHere's a patch that includes everything but the test documentation. I will start that now against what is currently in trunk, but I just wanted to get this stuff up and reviewed so that I don't get too out of sync with trunk before getting any feedback.
I had a bit of confusion rebasing this, so if it is poorly formatted, I may need to re-roll.
Comment #29
Cameron Tod CreditAttribution: Cameron Tod commented[removed duplicate post]
Comment #30
Cameron Tod CreditAttribution: Cameron Tod commentedComment #32
Cameron Tod CreditAttribution: Cameron Tod commented#28: user-documentation_cleanup_sprint-1326666-28.patch queued for re-testing.
Comment #34
jhodgdonLooks like the patch needs a re-roll...
Comment #35
drnikki CreditAttribution: drnikki commentedrerolled
Comment #37
Cameron Tod CreditAttribution: Cameron Tod commentedI have attempted to fix these issues a few times, but I just can't get the old, out of date patches to apply at all to the vastly different code thats now on trunk. I really don't want to manually reintegrate the patch.
Does anyone have any tips on how to get those old changes onto the current trunk short of doing it all manually?
Comment #38
jhodgdonFirst of all, probably drnikki and cam8001 should figure out who is working on this, and assign the issue, because obviously having two people both working on it wouldn't be great! :)
Second, rerolling. There are some suggestions here: http://drupal.org/patch/reroll
Also, if you use the "patch" command to apply the patch instead of "git apply", there are some "fuzz" options that can help, and it will also apply as much as it can and create a .rej file to show you which parts it can't figure out. That will probably reduce the parts that need to be applied manually quite a bit.
Comment #39
Cameron Tod CreditAttribution: Cameron Tod commentedI'm happy to step aside if you're happy to step up, drnikki :P
Comment #40
drnikki CreditAttribution: drnikki commented@cam8001 - i honestly dont mind doing it. I just picked it because I was at the NYC camp sprint and was looking for something to work on. I also certainly didn't mean to overstep. I'm on IRC if you want to chat - drnikki - and we can figure out why both of our patches failed. :)
Comment #41
drnikki CreditAttribution: drnikki commentedtaking it
Comment #42
drnikki CreditAttribution: drnikki commentedrerolled the patch from #26 so it applies to 8.x. I couldn't get the later patches to apply to anything cleanly. I'm guessing I'll have to do those manually once this passes testing.
Comment #43
Cameron Tod CreditAttribution: Cameron Tod commentedNIce work!
Comment #44
drnikki CreditAttribution: drnikki commentedIncluding notes from above.
Comment #47
jhodgdonThis looks great, thanks! And in contrast to some other cleanup issues that have been sitting around for 4-5 weeks with no review, I decided to review this one today...
A few things to fix up:
a) Form constructor functions: When there are arguments other than $form and $form_state, they need to be documented. This applies to quite a few of the functions in this patch, such as
b)
- The button is actually 'Delete role' (lower-case r)
- I have mostly seen the spelling "dialog" in documentation. Let's standardize on that (applies elsewhere in this patch also).
c) I think the code changes in the hook_help() are correct, but they need to be put on a separate issue.
d) in user_set_authmaps:
Should be IDs. "id" is a psychological term. "ID" means identifier.
e)
This isn't accurate. In D7 it would be hook_user_login() not hook_user op 'login'.
f)
We should get rid of junk lines like this.
g)
Needs the: "from the database".
h)
- This line exceeds 80 characters.
- Missing the @ingroup forms and the @see to the validate/submit functions.
i) In user_preferred_language():
Grammar: ... if there is more than one language enabled...
Comment #48
drnikki CreditAttribution: drnikki commentedI can move out the help text once this passes. I don't want to create too much confusion.
Also, re: "Form constructor for the multiple user account cancellation confirmation form." - it's *just* too long, so I added a line break, but I think a reword might be better. Just not sure which would be better.
Thanks for reviewing! It's almost done....
Comment #49
jhodgdonThanks! I think it still needs a bit more work... Looking at the interdiff:
a)
This doesn't follow our standards for param documentation (should start with capital letter and end with a period), and it should be a bit more grammatical, like "A user account object". Also, the parameter is $account (needs a $). The other added params have the same problems.
b) And regarding this change:
We really really really do not want the first-line description to wrap to two lines, or to exceed 80 characters. How about making it:
"Form constructor for the multiple account cancellation confirmation form."
?
c) Also I think you didn't get all the "dialogue" spellings in there. :)
Comment #50
Cameron Tod CreditAttribution: Cameron Tod commentedIn the spirit of teamwork.
Also:
I think we got them all?
Edit: Mucked up the interdiff sorry :( Plz ignore
Comment #51
Cameron Tod CreditAttribution: Cameron Tod commentedComment #52
jhodgdonThis looks mostly great! Just a couple of things to address:
a) This coding change to user_help() seems to contradict itself (one change goes in one direction and the other seems to reverse it) and is *not* part of the API docs cleanup -- please file a separate issue and remove this from the patch:
b)
I think the @see lines here can be omitted -- the first is covered by the new summary line, and I think (?) the second points to the function that is being documented (not sure about that)?
c)
This function needs some @param docs... also is it a form constructor? is it a page callback? If so, document as such.
d)
I think this should be starting with "Page callback"?
Comment #53
Cameron Tod CreditAttribution: Cameron Tod commenteda) Reverted to the same as head.
b) Removed the redundant @see. The other one refers to a different form entirely, as the multiple user cancel workflow is a bit complex and requires a reference I think.
c) This has been changed to "Form constructor: processes a one-time login link."
d) Changed.
Note that the following functions have been removed entirely from head (ea25df), so they have fallen out of the patch.
user_register_form
user_register_validate
user_register_submit
user_profile_form_validate
user_profile_form_submit
Issue for their removal is here:
#1499596: Introduce a basic entity form controller
Comment #54
Cameron Tod CreditAttribution: Cameron Tod commentedComment #55
Cameron Tod CreditAttribution: Cameron Tod commentedRebased for current head.
Comment #56
xjmThanks @cam8001 for keeping this issue moving. I reviewed the full patch and just found a couple things:
The parameter name should be listed with the
$
:$rid
, and the description needs capitalization and a period. Also, we should be a little more specific. I looked up user_admin_permissions() in the API docs and I'd suggest:Let's explain here how the role is used in the function (see previous example).
This change is not correct.
Comment #56.0
Lars Toomre CreditAttribution: Lars Toomre commentedAdded link to type hinting follow up issue.
Comment #57
Lars Toomre CreditAttribution: Lars Toomre commentedThe attached patch takes the patch from #55, incorporates the changes from #56 and includes further changes, as appropriate, from a detailed review of the top level files.
My sense is that once this is reviewed and committed, the top level files will need one more pass to be pretty well compliant with httP://drupal.org/node/1354. I have left the issue of correcting the Test files to another patch go round.
Comment #58
Lars Toomre CreditAttribution: Lars Toomre commentedI added a small patch in #1800174-3: Add missing type hinting to User module docblocks that adds missing type hinting to the hook functions in user.api.php file.
Comment #59
jhodgdonThanks for the patch! I reviewed about 2/3 of it carefully (skimmed the rest too), and found a number of one-time or recurring things that need to be cleaned up:
a)
Needs another space of indent in the @return -- same here (second line):
b)
constructor is misspelled; also take out "to return a" and rewrite slightly -- standards are at http://drupal.org/node/1354#forms
c) Could use a "the":
d)
This is a page callback, so the first line should have prefix "Page callback: " on it.
e) First line verb tenses in user.api.php are incorrect for hooks, see
http://drupal.org/node/1354#hooks
f) This line in user_load_multiple has an extra space after .:
As does this one in user_password():
g) First @param needs description:
h)
Omit @param/@return for form constructors and needs @ingroup and @see to validate/submit functions.
i)
spelling: othersie
j) user_register() and user_register_access() and similar functions - we don't ever say "Menu callback" -- should be "Page callback" and "Access callback" -- see http://drupal.org/node/1354#menu-callback -- this applies to user_page_title() too.
k)
Needs comma before "or" -- applies to user_uid_optional_to_arg() too.
l)
wether is misspelled ... not sure what this means either? maybe a little rewrite or a comma?
m) Did I already say this? e.g. is often mispunctuated... should be "the text; e.g., a, b, or c".
Comment #60
Cameron Tod CreditAttribution: Cameron Tod commentedHere we go!
I ran some spellchecks through and cleaned up all I could find.
Comment #61
jhodgdonThis patch needs to have all the cleanups that are not specifically part of our written-down standards, or that are not cleaning up actual documentation, removed from it.
For instance:
We do not have a standard that requires @ingroup to be separated from @see by a blank line; nor a standard that says @ingroup comes after @see. Putting changes like this into the patch wastes reviewer/committer time. Please supply a new patch without this type of change, and then I'll be happy to review it fully.
Comment #62
Cameron Tod CreditAttribution: Cameron Tod commentedNot sure how those got in! Heres an amended patch.
Comment #63
jhodgdonThanks! Looks better.
A few things to address:
a) In user.api.php:
I think this order was more logical previously (was change in a misguided attempt to alphabetize @see which is not in our standards). There are still a bunch of these changes in the patch. Please remove them. The one for user_login_default_validators() in user.module is especially blatantly more illogical as an alphabetical list too.
b) This change at the top of user.module is also applying a non-existent "standard" that seems to be "use lines for vendor classes should be separate from our own classes":
Moving the @file to the top is good, but leave the use lines as they were.
c) user.module
"as a string"... this is not adding any useful information. Just clutters up the documentation.
Same with this addition of "defaults to NULL":
Same with "as a string" here:
There are a bunch of other examples... check the patch.
d) user.module
if you are going to fix this line really, take out "for" and put a comma after e.g. (e.g. means "for example").
e) user.module - Access callbacks by convention do not have @return docs
f) user.module
url -> URL
g) user.module
The wording here is unclear to me. The "otherwise" clause belongs in the first sentence, not the second.
h) user.module
This kind of change, where you add "This function..." before some perfectly good existing documentation, is not necessary at all and adds clutter. Please remove these changes -- there are several in the patch.
So's this one later in the same file:
And this added "a" does not add clarity in the same file:
i) user.module
Bad list indentation and missing a * on one line.
j) user.module
This is not a good @ingroup. The batch topic is for the core basic batch functions. Not sure why this was added? Take it out of every place it was added (there are several in the patch).
k) user.module
huh? First line description isn't illuminating.... Say what the page shows.
l) user.module
This @see is not appropriate.
m) user.module - doc for _user_mail_notify():
Should be "e-mail messages". We use a hyphen as per the style guide, and e-mail is not countable so it cannot be pluralized with an s.
n)
This documentation does not make sense to me. I cannot figure out what is being returned.
o) user.pages.inc
The @param needs some attention. Arrays don't hav earguments and $account is not the array key.
p) user.pages.inc
unix -> UNIX
And that @throws needs the name of an exception class.
And don't say "the $account". If you want to use $account, don't use "the". If you want to use "the", don't use a $ on "account".
q) While you're at it, you could fix the first line for user_page() in user.pages.inc -- totally inaccurate.
Comment #64
Cameron Tod CreditAttribution: Cameron Tod commentedI am sprinting at a Drupal drop-in tommorow, so I will clean up these issues then. Could I ask that no one else works on this patch until then? It seems a lot of issues were introduced at some point in this comment queue which I am now going to have to track down and clean up. I'm not sure where a lot of these things come from, so I want to get back to a clean state.
Comment #65
jhodgdoncam8001 - thanks! Assign the issue to yourself. :)
Comment #66
Cameron Tod CreditAttribution: Cameron Tod commentedComment #67
grendzy CreditAttribution: grendzy commentedI would like to add documentation on the $method parameter to
user_cancel()
.#62 no longer applies to 8.x-dev and I'm not able to re-roll right now, but here's a small patch for user_cancel.
Comment #67.0
grendzy CreditAttribution: grendzy commentedWhoops added to wrong sub-section.
Comment #68
jhodgdonThese issues are a lot of work with very little tangible payoff, so I'm closing the rest of them as "won't fix". Your efforts on working on this issue were appreciated... it was just my fault for starting a task that was very difficult to get right.
Let's instead put our effort into fixing and reviewing documentation that is really unclear and/or wrong, and I hope that the people who worked on these issues are not afraid to jump into a more reasonable issue!