There are two problems with hook_help():
a) It's really a system hook, not a help module hook. The reason is that it is invoked by the Drupal core system to build the System Help block (which is NOT in the Help module). So, it belongs in a *.api.php file under core/modules/system, not in core/modules/help/help.api.php as it is now.
b) The text does not explain how the help is displayed. It should. Module developers need to know:
- Help overview pages for modules are displayed by the Help module, as topics on admin/help and as links from the Extend modules list page (if the Help module is enabled).
- The System Help block displays page-specific help when you are on a page that has help text defined.
- If such a page is displayed in a modal dialog, the page-specific help is displayed at the top.
Note: this last feature depends on the patch to #2260095: Help not displayed within modals (like when adding a new block to layout) going in, so maybe we shouldn't mention it yet.
See also #2261083: Help module help mentions context-sensitive help and shouldn't
This should be a good Novice project to make this patch.
Comment | File | Size | Author |
---|---|---|---|
#30 | interdiff-2263047-29-30.txt | 1.49 KB | amitgoyal |
#30 | hook-help-update-2263047-30.patch | 1.59 KB | amitgoyal |
#12 | hookhelp_moved_to_system-2263047-12.patch | 5.21 KB | martin107 |
Comments
Comment #1
jhodgdonApparently this is true in D7 as well. So this will need a backport.
Comment #2
jhodgdonI just filed a meta-issue where we need to discuss the top-of-page help:
#2263359: hook_help(): Top of page help sections can't link to help pages without a fatal error or checking for help module
Comment #3
sachin_s CreditAttribution: sachin_s commentedComment #4
sachin_s CreditAttribution: sachin_s commentedI've moved the hook definition to system.api.php. Also, updated its documentation to mention the role of the Help module in the overview help page at admin/help.
There are two patches, for D7 and D8.
Thanks.
Comment #5
sachin_s CreditAttribution: sachin_s commentedComment #8
jhodgdonPlease do not put D7 patches on D8 issues. Read:
https://drupal.org/node/1319154#multiple-versions
The D8 failures... seem unrelated.
So I reviewed the patch. It is mostly OK but:
a) The first line -- that is not accurate. hook_help() is used for both page-level and module-level help.
b) In several places, there are two spaces between sentences. There should only be one.
c) I think in the first paragraph we should say "for specific routes" instead of "for specific paths".
d)
That first sentence is not accurate -- only the page-specific help appears in the system help block. And the second sentence should not say "Please note that" -- it should just say that the Help module (if enabled) displays the module-level help... actually you will get a link on admin/help and also a link from the Extend page.
e)
How about here saying "for page-specific help" and "for module overview help"? I think that would be clearer.
f)
Maybe it would be helpful to add that this can be used in conjunction with the route to further define what help should be displayed for page-specific help?
g) The example code is not all that great. The module-level help is not a good example (it doesn't follow our established standards), and the route-specific example does not include an example that uses the $request parameter. Could we:
1. Copy in a module-level help that follows our guidelines (possibly somewhat simplified)? There is one on the http://drupal.org/node/632280 help guidelines page.
2. Add an example that uses the $request parameter? Several core modules are doing this... node.module is one example. You can mix examples from different modules -- just add a comment explaining what the purpose of each example is and where it comes from.
Comment #9
sachin_s CreditAttribution: sachin_s commentedThanks jhodgdon, I will reissue the patches with all these points considered.
Comment #10
sachin_s CreditAttribution: sachin_s commentedThe points mentioned in the previous review have been addressed. Please review the new patch.
Comment #11
jhodgdonThanks for the new patch! Generally you should make an interdiff file when you make a new patch, especially if you made a lot of changes or the patch is large, or both. See https://drupal.org/documentation/git/interdiff
Anyway, I reviewed the new patch. It looks really good!
The only things I would change are fairly minor (mostly grammar/wording):
a) When referring to specific examples, I think instead of saying "see block.module" I would say "see block_help()", because this will link them to the actual function that provides the help. (same for content_translation.module ==> content_translation_help())
b) The first paragraph talks about help for specific routes, and the 2nd starts talking about page-specific help (which is the usage in the rest of the help). So I think in the first paragraph, we should change "or for specific routes" to say "or for specific pages".
c)
Remove "the" in all 4 lines.
d)
You cannot put @see in the middle of the help, and so this should be made into a link, something like:
e)
Remove "the" in "For the" in both sentences.
f)
information is not countable, so the grammar here is not correct ... I think the second sentence should be something like this:
This can be used to generate different help output for different pages that share the same route.
Comment #12
martin107 CreditAttribution: martin107 commentedImplemented changes from #11.
Comment #13
jhodgdonLooks good to me, thanks!
Comment #14
jhodgdonOh... I think that after moving this hook, there is nothing left in help.api.php, so it should be removed?
Comment #15
martin107 CreditAttribution: martin107 commentedRemoved file.
Comment #16
jhodgdonThanks! I think we're good to go now.
Comment #17
jhodgdonThanks again all! Committed to 8.x.
We also need to backport to 7.x. Keep in mind that hook_help is a bit different in 7.x (uses paths and not routes, and the first argument to indicate the module-level help is not the same).
Comment #18
sachin_s CreditAttribution: sachin_s commentedComment #19
sachin_s CreditAttribution: sachin_s commentedPlease review the patch backported to 7.x. Thanks!
Comment #20
lostkangaroo CreditAttribution: lostkangaroo commentedLooks good to me pretty simple backport.
Comment #21
jhodgdonCould we fix this formatting problem (not introduced by this patch, but present in the existing hook_help() documentation for D7) please?
I think that the last two lines could just be removed here (not needed), and the line before that can be moved up to the end of the previous line.
Maybe this should just say, "For the help page for the module as a whole, $path will have the value 'admin/help#module_name', where 'module_name" is the machine name of your module.'
I think this would be sufficient and clearer, given the added documentation above that explains the dual purpose of hook_help?
Comment #23
joshi.rohit100uploaded patch for D7.
please review now.
Comment #24
jhodgdonLooks good, thanks!
Comment #25
amitgoyal CreditAttribution: amitgoyal commented@jhodgdon - I am bit late to comment here but there seems to be following two issues with the patch in #15 for 8.x branch,
<a href="@blocks"> should be <a href="!blocks">
Comment #26
jhodgdonThanks, amit! You are right, and I missed those! But rather than going back now on this issue, we have another issue open to update the system help on #2091363: Update hook_help for System module, so we can just fix it there. The rest of the system help suffers from the same problems.
Meanwhile, committed the patch in #23 to Drupal 7.
Comment #28
jhodgdonOh wait, in #25 you are talking about the hook_help() docs, not the system_help() function. Yes, let's go back to Drupal 8 and fix that problem. We shouldn't have an example in the hook_help() docs that sets a bad example!
Comment #29
joshi.rohit100update the hook_help() doc as mentioned in #25.
Comment #30
amitgoyal CreditAttribution: amitgoyal commentedThanks @joshi.rohit100 for the patch.
I think we can also add a condition to check if the block module is enabled or not. Please review revised patch.
Comment #32
jhodgdonRE #30, this is an example of the main help from the block module, so we do not need to check if the block module is enabled.
The patch in #29 is fine, though. I committed it to 8.x and I think this issue is (again :) ) done. Thanks!