Problem/Motivation

It's best practice for Drupal modules to provide help using hook_help() for the help.page.[module-name] path. This provides module-specific info on the core help landing page: https://www.drupal.org/documentation/modules/help

We should also add a help_example module which demonstrates this hook and its best practices in detail.

Proposed resolution

Implement hook_help() for each example module, for the help.page.[module-name] path. This will provide module-specific information for the help page.

Do not add hook_help() per controller path, because that will be confusing for anyone reading the code.

Add a help_example module.

Remaining tasks

User interface changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dbt102 created an issue. See original summary.

dbt102’s picture

dbt102’s picture

Assigned: dbt102 » Unassigned
Status: Active » Needs review
navneet0693’s picture

+++ b/examples.module
@@ -27,6 +28,35 @@ use Drupal\Core\Url;
  */
...
+   $output = '';

Let's have a look at this issue to avoid lots of text, did you ran it through phpcs? It might have thrown an error of coding standards related to concatenation with t() function.

See: #2660058: [meta] Convert controller content to twig {% trans/endtrans %} templates per module

navneet0693’s picture

Status: Needs review » Needs work
minakshiPh’s picture

Assigned: Unassigned » minakshiPh
minakshiPh’s picture

Assigned: minakshiPh » Unassigned
Status: Needs work » Needs review
Issue tags: +Quick fix
FileSize
3.6 KB
3.8 KB

Updated the patch with coding standards and as mentioned in #5

Status: Needs review » Needs work

The last submitted patch, 7: Add_HELP_to_Examples_for_Developers-2723625-7.patch, failed testing.

minakshiPh’s picture

Status: Needs work » Needs review
FileSize
3.6 KB

Re-rolled the patch.

Kindly review.
Thanks!

dbt102’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for fixing up the -2 patch @minakshiPH .

The -9 patch applied cleanly. And, I looked at the code to see exactly what changes were made (just so I understand). Tested the patched module on a _dev site and the HELP section look good.

Mile23’s picture

Title: Add HELP to Examples for Developers » Add hook_help()/help_example to Examples for Developers modules
Category: Task » Plan
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: -Quick fix

Thanks for working on this.

As much as possible we want to use twig translatable templates for big blocks of content like this. Examples has Drupal\examples\Utility\DescriptionTemplateTrait to help out with this in controllers. I'd guess it would work returning appropriate markup for hook_help() as well.

We've also historically had some conversations as to whether Examples modules should always have hook_help(): #2123195: [policy] Change approach on end user ui We want to err on the side of having useful explanatory content on the page, rather than relying on help text, but both could work if presented properly.

If you want to talk about whether to add hook_help() to some or all of these modules, let's have that conversation here. Then we can open sub-issues as needed to add hook_help() to the different modules.

We should also consider adding an example of how to use hook_help(), both with and without the twig templating system.

Rescoping this issue to be a PLAN.

Mile23’s picture

Title: Add hook_help()/help_example to Examples for Developers modules » [meta] Add hook_help()/help_example to Examples for Developers modules
Category: Plan » Task
Issue summary: View changes

Erp... Wait a minute. I made a mistake. :-)

This sets the help displayed in the module information page, rather than the help at the top of the page. That's a great idea, and we should do that for each module.

But we definitely want to use the twig template scheme to provide this content, so that it's translatable and doesn't make the code part of the module confusing. We want minimal how-to documentation in each example module for this help system.

We also want a follow-up to make a help_example so we can provide detailed documentation for all these things in that module, without having to provide a lot of confusing documentation within all the other modules.

Thanks. :-)

dbt102’s picture

I agree that each of the sub-modules would be improved by adding help per the Help text standard

I'd suggest that the commit be made for the main "Examples for Developers" module (this issue) and have that serve as an example for the remaining submodules.

I think it would be less confusing if a new [meta] issue be created rather than repurposing this one. Then this one could be referenced in the meta easy enough for tracking.
Then, a new issue could be created per sub-module. I think this would break it down into manageable chunks. I'd be glad to set this up.

I'm not clear about your ideas about the twig template schemes, because the Help text standard does talk a lot about translation, but does not discuss twig template schemes. The purpose of the Help text standard, and the overview help page is different than that of highly commented code. I always go to the help overview of a module just to get clued into the basics of what the module is about and how its used.

I'd be glad to help out with the overall effort, and the could help with the twig templates once one was completed.

Since HELP should be provided by all core and contrib modules, a submodule dedicated to this makes sense too. TOURs are optional, and there is a dedicated module for that. This makes it seem more obvious that HELP submodule should be there too.