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 menu 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
None.
Comment | File | Size | Author |
---|---|---|---|
#86 | menu_docs-1326672-86.patch | 24.31 KB | Albert Volkman |
#86 | interdiff.txt | 1.83 KB | Albert Volkman |
#83 | menu_docs-1326672-83.patch | 23.17 KB | Albert Volkman |
#79 | 1326672-79-menu-docs.patch | 30.67 KB | johnshortess |
#77 | 1326672-77-menu-docs.patch | 35.54 KB | johnshortess |
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!
Actually, I don't think this issue is in the list on the summary issue.
Comment #2
xenophyle CreditAttribution: xenophyle commentedI'll take this.
Comment #3
xenophyle CreditAttribution: xenophyle commentedComment #4
jhodgdonThis looks pretty good! Here are a few things I would suggest changing:
a)
How about "The type of operation being done" or something like that? "should allow" doesn't seem right.
(Same for the form constructor below -- the one for the menu as a whole as opposed to an item)
c)
a link -> the link [this is a definite link]
d)
No "." at end.
e)
This is from menu.api.php... Normally, we document this type of hook (this applies to all three menu hooks) something like this:
Respond to...
e.g. Respond to custom menu creation.
The reason being that we're documenting what the implementing module is doing, not what the hook invoker is doing.
f)
Find -> Finds
Comment #5
xenophyle CreditAttribution: xenophyle commentedThanks for your help.
Comment #6
jhodgdonThis looks really good! The only things I saw to fix:
a)
Typo -- Respond is misspelled... and the sentence doesn't make sense (omit "was").
b)
Indentation has extra space in that second @param doc area.
Comment #7
xenophyle CreditAttribution: xenophyle commentedI don't know how you noticed the indentation problem, but nice catch.
Comment #8
xjm@jhodgdon can spot an error in patch whitespace at 20 paces. :)
Comment #9
sven.lauer CreditAttribution: sven.lauer commentedThis is looking good. Read through the patch and applied it to see if anything else is amiss.
Only remaining issue: The .js and .css files don't have @file doc blocks.
Comment #10
xenophyle CreditAttribution: xenophyle commentedI didn't think css and js files were supposed to have @file blocks; I thought they were just for php. The @file block is what adds the file to http://api.drupal.org/api/drupal/files, isn't it? It doesn't seem to be the convention to include js and css. But maybe this just shows that everyone has been doing it wrong?
Comment #11
xjmWell, they've required adding them to CSS files in the CSS cleanup sprint for the HTML5 initiative, and so we started adding those that were missing as well for the docs sprint. We also confirmed that the docblocks are stripped during CSS and JS aggregation, so they do not add any overhead.
Comment #12
xenophyle CreditAttribution: xenophyle commentedHere's the patch with the changes.
Comment #14
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedRerolled your awesome patch.
Comment #15
sven.lauer CreditAttribution: sven.lauer commentedThe re-roll in #14 is from an old version (does not include @file headers, has the "Rspond" pointed out in #6 ...).
Comment #16
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedMhh ... looks like #12 had them, too.
Comment #17
sven.lauer CreditAttribution: sven.lauer commentedTrue, #12 has "Rspond" (so maybe the reroll there was against a previous version?), but it does have the @file headers for the css files.
Comment #18
xenophyle CreditAttribution: xenophyle commentedNot sure how I messed up patch #12 and left out those fixes, but here's another try.
Comment #19
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedLooks very good and consistent in itself. One really, really, really minor point:
Here the path is above the summary.
The path is below the summary here. Decide for one way?
Comment #20
sven.lauer CreditAttribution: sven.lauer commentedNiklas means the first paragraph after the one-line summary. I think general practice is to have the Path:-line as the first line after the one-line summary (and that is also how it is in the example in the doxygen standards).
Comment #21
Niklas Fiekas CreditAttribution: Niklas Fiekas commented@sven.lauer: Exactly. Thanks for clarifying. Fixed the typo.
Comment #22
xenophyle CreditAttribution: xenophyle commentedOk, I have fixed the minor point. Thanks for the review.
Comment #23
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedAwesome, thanks.
Comment #24
sunI'm very uncomfortable with documenting menu router paths in phpDoc of functions. I'd almost say that's invalid to do. Where was this decided?
Likewise, stuffing a @see to a hook_menu() implementation into every page/access/title/whatever function callback is very debatable, too. The function callback and the hook_menu() implementation are only marginally related. Again, where was this discussed?
Comment #25
sven.lauer CreditAttribution: sven.lauer commentedI see you've found #1315992: No standard for documenting menu callbacks already. I'll reply there.
Comment #26
jhodgdonThe standard has been updated:
http://drupal.org/node/1354#menu-callback
So this patch will need an update.
Comment #27
jhodgdontagging
Comment #28
Anonymous (not verified) CreditAttribution: Anonymous commentedSince there hasn't been activity for 4+ weeks, I'm going to move this back to unassigned.
Comment #29
johnshortessWorking on this at the DrupalCon core office hours sprint...
Comment #30
johnshortessAfter a brief delay due to my flight home from Denver, here's a reroll of @xenophyle's patch in #22, based on my understanding of the new standard in http://drupal.org/node/1354#menu-callback and @sun's comments in #24. My very first core patch--keeping fingers crossed that I did everything right!
Comment #32
johnshortess#30: menu-clean-up-documentation-1326672-30.patch queued for re-testing.
Comment #33
xjmNice job @johnshortess! Thanks for taking this up.
I did a full textual review of the patch (did not apply it) and found the following things to fix (most of which are oddities related to SimpleTest docs):
These blank lines should be removed (on either side of the removed hunk).
This change does not need to be made (as it's an inline comment rather than a docblock), so I would remove it.
For this, let's say "Tests menu administration" or "Provides tests for menu administration." These classes do not have constructors, so "represents" doesn't fit, I don't think.
For these, let's make sure to add a blank line after each variable before the next docblock.
At present, we exclude docblocks for
setUp()
andgetInfo()
(and there isn't actually a defined interface for them) so these hunks can be removed. References: http://drupal.org/node/325974, #338403: Use {@inheritdoc} on all class methods (including tests)Let's try to reword these so they fit on one line that is 80 chars or less.
Should read:
...using the Menu module UI.
Reference: http://drupal.org/node/604342
I'd add an article here ("the menu link").
"ID" should be capitalized.
For this one, I think "Tests menu settings for nodes" would be the best summary.
I'd say "...creating, editing, and deleting menu links..."
Finally, one other thing to add might be @return for some of the page callbacks (I think some but not all were missing them). In #1315992: No standard for documenting menu callbacks we decided that we should document the return values since a page callback might return either a render array or a string.
For @johnshortess or whoever rolls, the next patch, it would be good to include an interdiff along with the full patch, so that we can easily review the changes made. Thanks!
Comment #34
johnshortessThanks, xjm. Here's a new patch, and an interdiff.
Comment #35
johnshortessOkay, let's try this again. New patch, less whitespace.
Comment #36
xjmThanks @johnshortess! The changes in the interdiff look good to me. I did notice a few more things when I reviewed it this time:
I think this should be "via the node form widget"?
For clarity, I'd reword this a little (remove the comma and say "so that other modules are..." rather than "so other modules are...").
I think the extra blank line should not be added here.
It looks like these parameters are optional, so the descriptions should begin with
(optional)
and then mention the default value at the end. Reference: http://drupal.org/node/1354#param-return-data-typeI think this should be "via the node form widget"?
As before, an interdiff would be helpful with the updated patch. Thanks!
Comment #37
xjmI noticed something else when debugging #1468420: Submenus of a parent menu item that links to the front page (<front>) do not show when viewing the site's front page.. These two arguments default to
NULL
, so as I mentioned before they should be documented as optional and have the default value specified.In this particular case, though, it appears that (while these second two arguments are optional), if you specify one, then you must specify both. So, let's add that information to the docblock.
Comment #38
jhodgdonI'm going through these issues and un-assigning any without activity for several weeks. If you still want to work on this issue, please feel free to assign it back to yourself. Thanks!
Comment #39
drnikki CreditAttribution: drnikki commentedHere's a reroll of the one above. Let's see if this passes, then I can add the comments.
Comment #40
drnikki CreditAttribution: drnikki commentedComment #42
jhodgdon#39: menu-cleanup-doc-1326672-38.patch queued for re-testing.
Comment #44
drnikki CreditAttribution: drnikki commentedDAMMIT. I'll re-reroll when I get to work tomorrow. Trying to do a few of these in between projects this week.
Comment #45
drnikki CreditAttribution: drnikki commentedpatch from #35 rerolled.
Comment #46
drnikki CreditAttribution: drnikki commentedAbout the comments in #36, it looks like the link about @param defaults has it on the same line, rather than at the end. Can you clairify which is correct and I"ll add that to the patch with an interdiff.
I've seen things like this
Comment #47
jhodgdonThe formatting in #46 looks good, aside from some places where there are two spaces after (optional) and some descriptions that don't have a "." at the end. Also, we usually say "Defaults to 0." rather than just "Default 0" -- generally, we try to use natural English wording rather than being terse.
Comment #48
drnikki CreditAttribution: drnikki commentedThanks, jhodgdon. This needs another reroll before any more changes can be made. I'll get on that as soon as I can.
Comment #49
jhodgdonstatus as per #47/#48
Comment #50
Albert Volkman CreditAttribution: Albert Volkman commentedNo additional fixes, just a reroll to apply to current head.
Comment #51
Lars Toomre CreditAttribution: Lars Toomre commentedThe attached untested patch builds upon the work done through #50. An interdiff is also attached.
This further cleans up the menu module documentation and particularly addresses the two test classes for this module. It will probably require a re-roll because I no doubt have overlooked something. Comments and reviews are welcome.
Comment #52
jhodgdonThanks! I started over reviewing this patch, and it looks pretty good. A few things before it is ready to commit:
a) menu.admin.inc
Why was @param $delta taken out here? I agree that the doc isn't good, but we need something. :)
b) This patch is ... odd. There are two different sections for several of the files (menu.admin.inc, menu.module, etc.). I only reviewed the first sections... please redo the patch.
c) There are code changes in here -- please don't make code changes part of this API docs cleanup effort. Example from one of the tests:
At this point, I stopped reviewing... the patch has some stuff in it that I think just doesn't belong on this issue?
Comment #53
Lars Toomre CreditAttribution: Lars Toomre commentedSorry about that patch @jhodgdon. Looks like I forgot to squash it before doing git format-patch. I will re-roll when next at development machine.
I thought the variable name changes since they did not change code, but simply made them meet camelCase coding standard.
Finally, I am not sure what happened on your first point. I will address that tomorrow AM.
Comment #54
Lars Toomre CreditAttribution: Lars Toomre commentedHere is a squashed and untested patch that addresses #53.a and #53.b. Sorry about forgetting to squash when I rolled #51.
Comment #55
Lars Toomre CreditAttribution: Lars Toomre commentedGrr... I need to remember to change the status.
Comment #56
jhodgdonPlease take out the code changes, such as:
I know you are trying to be helpful, but this effort is *only* for documentation header changes, as noted above. There is a separate effort underway for cleaning up other coding standards issues, if you want to get invovled -- #1518116: [meta] Make Core pass Coder Review -- and we really are trying to keep these different clean-up efforts contained and limited to what they are supposed to cover.
Thanks!
Comment #57
Lars Toomre CreditAttribution: Lars Toomre commented@jhodgdon I will do so later today thanks.
At the moment, I am working through one patch that covers all of the changes such as the one you highlighted in #56. It also will rename properties such as $this->big_user that you commented about elsewhere in one of these issues.
I will post a link to that issue here when I get it finished and then focus on a re-roll here.
Comment #58
jhodgdonLars: I believe there's already an issue on that "coder clean-up" for the Node module -- please post your patch there (more relevant; it's not related to this effort).
Comment #59
Lars Toomre CreditAttribution: Lars Toomre commentedI just commenting because the change you did not want in #56 will be moved to the forthcoming patch which cuts across all modules.
Comment #60
Lars Toomre CreditAttribution: Lars Toomre commentedWow... It took me far longer to create an appropriate #1803656: Improve Tests consistency to standards in modules A-M.
Admittedly, this issue is both a combination of documentation and coding standards. This might make it hard to review. However, given how these tests get applied in the first place, I think this approach is appropriate.
Comment #61
Lars Toomre CreditAttribution: Lars Toomre commentedHere is an updated and untested patch that does include any variable renames as requested in #56.
Comment #62
jhodgdonThere is still a code addition at the top of this patch -- where is this coming from?
I took a quick scan through the rest of the file... it looks pretty good on first glance (obviously it will need a more careful review)... I did notice that one added @file block (CSS file) needed a blank line after it:
http://drupal.org/node/1354#files
And technically, this type of change (and re-wrapping in-code comments) is out of scope for this issue and belongs on the "Bring core up to coding standards" issue instead:
These changes also have more possibility of conflicting with other (code) patches, so maybe you could move those hunks over to #1533252: Make menu module pass Coder Review instead so that the code cleanups are contained there?
Thanks!
Comment #63
Lars Toomre CreditAttribution: Lars Toomre commentedHere is an untested patch that addresses the items in #62.
The $admin_user documentation was coming from trying to document an undeclared member of that test class. For now, I have simply removed it since I am lost when something is documentation, when it is coding style and when it is just trying to fix recognized violations of Drupal standards.
Comment #64
Lars Toomre CreditAttribution: Lars Toomre commentedGrrr... Need to remember to set status.
Comment #65
jhodgdonRE: what is in scope for this issue -- see the issue summary above or the issue summary for the meta-issue that this is part of... haven't we been through this on some other issues?
Anyway, basically, what's in scope is things in API docs comments (between /** */ that is), with param/return types specifically excluded. Anything that is not in an API doc comment is definitely excluded, and the main cleanup goals are listed in the bullet points of this issue summary. So. It would be great, if you want to contribute patches to the "API Docs Cleanup" issues (which is most welcome!), if you could confine your patches to just /** */ comments. Thanks!
On to reviewing this patch -- it's mostly great! I'd like to see a couple of things in added documentation fixed before it gets committed though:
a) The word "id" is a psychological concept (ego, superego, id), while "ID" is an abbreviation for "identifier". Such as here:
Should be "link ID".
b) It would be great if the revised documentation lines followed better grammar, such as:
c) The word "Boolean", used in documentation text, should always be capitalized, such as here:
d) I didn't look at the code to be sure, but:
If this is actually a page callback used in menu_menu(), it should be documented as "Menu callback: Form constructor for...". If it isn't, it probably doesn't need @see menu_menu().
e) Need a blank line after @file doc block: [menu.js too]
f) Hooks in api.php file -- verb tense standard is different (and incorrect in the original and this patch). See
http://drupal.org/node/1354#hooks
g)
This seems... slightly confusing or contradictory? I think if all the information about the return value was put into the @return, it would be clearer, because it would probably say something like "A JSON response object containing the menus and menu items as a JavaScript array" or something like that. As it is, one line seems to say it's just returning a JS array, and the other says it's a JSON object.
h)
- There's a stray blank line between doc and function
- Generally this doc doesn't make the function clear to me and I'd have to read the code to figure out what's going on (never a sign of great documentation!). For instance, the return value says it's an array of menu items... I don't think so. Menu items elsewhere are arrays, and this can't be an array of menu item arrays if it's to be used as a select? Then param $item mentions it's generating a list of parents, but elsewhere it's not talking about parents... I'm not sure which is correct but something's wrong... I guess maybe it's generating a list of *possible* parents to assign $item to? but I'm not sure. Anyway, I think it needs a bit more attention to really document what the parameters and return value are.
i) The next function in the patch, _menu_parents_recurse(), has the same problem about mixing up an options list with menu arrays in its $options param docs.
j)
Stray extra space (this is the last line of the patch, not sure what function it is documenting)
Comment #66
Lars Toomre CreditAttribution: Lars Toomre commentedAs I stated in #51, my patch there builds upon the work that was done through #50 as have my patches since. I did not check the wording that others had added.
This untested patch addresses all of #65 except item h).
Comment #67
Lars Toomre CreditAttribution: Lars Toomre commentedGrrr.. need to set status.
Comment #69
Lars Toomre CreditAttribution: Lars Toomre commented#66: 1326672-66-menu-docs.patch queued for re-testing.
Comment #70
Lars Toomre CreditAttribution: Lars Toomre commentedI added a small patch in #1800774-1: Add missing type hinting to menu_ui module docblocks that adds type hinting to the hook documentation for the Menu module in menu.api.php.
Comment #71
jhodgdonSetting patch to "needs work" since #66 says it doesn't address review item (h) yet.
Comment #72
Lars Toomre CreditAttribution: Lars Toomre commentedIf anyone else wants to address #65 h), please do so.
This patch needs a review anyways independently of @jhodgdon so that she can then commit whatever results.
Comment #73
johnshortessComing back to this for the first time since shortly after the sprint at DrupalCon Denver. Here's a reroll that includes my first attempt at #65 h).
Comment #74
jhodgdonI apologize, but I will probably not have time to review/commit this patch until January. :(
Comment #75
johnshortessNo problem! I have some time to devote to core this month and saw this piece of low-hanging fruit that I'd worked on back in March. In the meantime I'll be looking through the queue to see what else I can help out with while I have some free cycles.
Comment #76
jhodgdonI had some time today to review this patch... again, sorry for the delay!
It is mostly good! I found a few problems that need to be fixed:
a)
The blank line should not have been removed between these member variables. This problem appears several times in the patch.
b)
@var needs to be followed by the data type of the member variable. This problem appears several times in the patch.
c)
I don't think this method actually performs tests -- I think it is a helper function that just adds a menu. So the documentation should probably stay how it was (with a verb change from Add to Adds). Also applies to the addCustomMenu() method that follows, deleteCustomMenu(), etc.
d) In addMenuLink(), the default value for $menu_name in the documentation does not match the function signature. Actually, it would be better to omit all of the "Defaults to xyz" text in the documentation, because it makes the documentation less likely to be correct, at least if the default is easily seen in the function signature. I would only include a "Defaults to..." if the default is fairly complicated to explain and is not obvious from the function signature, or if the default has some special meaning, like "Defaults to xyz, meaning that ...".
e)
created is misspelled in the @return
f)
Form submission handlers should not have "@ingroup forms" in their documentation. That is only for the form generation functions.
g)
Typo -- that line containing "s".
h) Very bottom of the patch:
"menus" should either be menu (if it is being used as an adjective) or menus' (if it is possessive).
Comment #77
johnshortessOkay, I think this patch takes care of all of the items noted in #76. I also removed one hunk that changed documentation for a function (hook_block_info(), IIRC) that was removed in #1880620.
Comment #78
jhodgdonMuch better, thanks! There are still a couple of little issues to resolve:
a) MenuTest.php file:
It looks like this adds a blank line between the docblock and what it is documenting (it shouldn't), and then removes the blank line between this and the next docblock (it shouldn't).
b) later in that file, the addMenuLink() function:
I don't think it is really a "test" -- it's more of a utility function. We normally just document methods as "Tests..." if they start with the word test. I would leave the documentation first line saying "Adds a menu link..." rather than changing to "Tests the addition of a menu link".
c) menu.admin.inc - menu_overview_form()
Should be "Page callback:" not "Menu callback:". Same problem in menu_edit_item(), menu_edit_menu(), menu_configure().
d) menu.admin.inc - menu_edit_menu_submit()
Missing . at end of line.
Comment #79
johnshortessOkay, here we go again. It was kind of a hairy re-roll because of menus becoming entities. I skimmed through #1814916, but I think I need a full night's sleep before I can wrap my brain around all of the changes there. The patch applies, but it probably needs a review to make sure all of the docblocks are still current. In particular, there are a couple of @see directives pointing to menu_edit_menu(), which I don't think exists any longer.
Comment #81
johnshortess#79: 1326672-79-menu-docs.patch queued for re-testing.
Comment #82
jhodgdonThat is true: the function menu_edit_menu() does not appear to exist in Drupal 8. Setting this to Needs Work on that basis. I haven't reviewed the rest of the patch yet in detail, but it would be good if someone could check to see if the notes in #78 have been addressed.
Comment #83
Albert Volkman CreditAttribution: Albert Volkman commentedFirst a re-roll of #79.
Comment #84
Albert Volkman CreditAttribution: Albert Volkman commentedActually, it appears that all of the items in #78 have been addressed. This is ready for a review.
Comment #85
Pete B CreditAttribution: Pete B commentedGreat patch so far!
Still lots of coding standards issues not covered here though as well as the function changes as mentioned in #82.
menu.module line 240
needs a full stop at the end.
menu.admin.inc line 56
The @param is incorrect.
and line 479
should be on one line or in short/long format.
Happy to help out here if this is not being progressed further at the moment?
Comment #86
Albert Volkman CreditAttribution: Albert Volkman commentedI appreciate the review @Pete B! Here's a patch to fix those issues.
Comment #87
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!