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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Issue tags: +Needs backport to D7

Apparently this is true in D7 as well. So this will need a backport.

jhodgdon’s picture

sachin_s’s picture

Assigned: Unassigned » sachin_s
sachin_s’s picture

I'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.

sachin_s’s picture

Assigned: sachin_s » Unassigned
Status: Active » Needs review

The last submitted patch, 4: D7_patch_hookhelp_moved_to_system-2263047-4.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 4: D8_patch_hookhelp_moved_to_system-2263047-4.patch, failed testing.

jhodgdon’s picture

Please 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)

+ * The help information provided by this hook appears as a system help block
+ * on the page. Please note that the modules overview help page at admin/help
+ * is generated by the Help module.

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)

+ *   For a specific page, use the route name as identified in the module's
+ *   routing.yml file. For the help overview page, the route name will be in the
+ *   form of "help.page.$modulename".

How about here saying "for page-specific help" and "for module overview help"? I think that would be clearer.

f)

+ * @param \Symfony\Component\HttpFoundation\Request $request
+ *   The current request.

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.

sachin_s’s picture

Assigned: Unassigned » sachin_s

Thanks jhodgdon, I will reissue the patches with all these points considered.

sachin_s’s picture

Assigned: sachin_s » Unassigned
Status: Needs work » Needs review
FileSize
5.69 KB

The points mentioned in the previous review have been addressed. Please review the new patch.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks 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)

+ * For the detailed usage examples of:
+ * - The module overview help, see content_translation.module. The module
...
+ * - The page-specific help using only routes, see book.module.
+ * - The page-specific help using routes and $request, see block.module.

Remove "the" in all 4 lines.

d)

+ *   overview help should follow a certain standard structure.
+ *   @see https://drupal.org/node/632280

You cannot put @see in the middle of the help, and so this should be made into a link, something like:

... overview help should follow
@link https://drupal.org/node/632280 the standard help template. @endlink

e)

+ *   For the page-specific help, use the route name as identified in the
+ *   module's routing.yml file. For the module overview help, the route name
+ *   will be in the form of "help.page.$modulename".

Remove "the" in "For the" in both sentences.

f)

+ *   The current request. This can be used to generate a customized
+ *   page-specific help information.

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.

martin107’s picture

Status: Needs work » Needs review
FileSize
2.39 KB
5.21 KB

Implemented changes from #11.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, thanks!

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Oh... I think that after moving this hook, there is nothing left in help.api.php, so it should be removed?

martin107’s picture

Status: Needs work » Needs review
FileSize
352 bytes
5.3 KB

Removed file.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! I think we're good to go now.

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks 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).

sachin_s’s picture

Assigned: Unassigned » sachin_s
sachin_s’s picture

Assigned: sachin_s » Unassigned
Status: Patch (to be ported) » Needs review
FileSize
7.75 KB

Please review the patch backported to 7.x. Thanks!

lostkangaroo’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me pretty simple backport.

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Could we fix this formatting problem (not introduced by this patch, but present in the existing hook_help() documentation for D7) please?

+ *   To provide a help page for a whole module with a listing on admin/help,
+ *   your hook implementation should match a path with a special descriptor
+ *   after a "#" sign:
+ *     'admin/help#modulename'
+ *       The main module help text, displayed on the admin/help/modulename
+ *       page and linked to from the admin/help page.

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?

  • Commit 122c9b4 on 8.x by jhodgdon:
    Issue #2263047 by martin107, sachin_s: Move hook_help to system.api.php...
joshi.rohit100’s picture

Status: Needs work » Needs review
FileSize
7.07 KB

uploaded patch for D7.
please review now.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

amitgoyal’s picture

@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,

  1. <a href="@blocks"> should be <a href="!blocks">
  2. url('admin/structure/block') should be \Drupal::url('block.admin_display')
jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, 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.

  • Commit 050aed3 on 7.x by jhodgdon:
    Issue #2263047 by joshi.rohit100, lostkangaroo, sachin_s, martin107: Fix...
jhodgdon’s picture

Version: 7.x-dev » 8.x-dev
Status: Fixed » Needs work

Oh 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!

joshi.rohit100’s picture

Status: Needs work » Needs review
FileSize
1.54 KB

update the hook_help() doc as mentioned in #25.

amitgoyal’s picture

Thanks @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.

  • Commit 1623fcc on 8.x by jhodgdon:
    Isssue #2263047 by joshi.rohit100, amitgoyal: Clean up hook_help example...
jhodgdon’s picture

Status: Needs review » Fixed

RE #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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.