Problem/Motivation

We should encourage developers to follow best practices for accessibility when building Drupal modules. The current Help Text Standards provide example code and a standard template for hook_help() implementations, which uses h3 as the heading level for section titles. The standard was adopted about 9 years ago, without a lot of discussion except along the lines of "better to have headers and a standard template than what we had before" on this issue:
#537828: Help text for core modules - update to conform to new standard

When hook_help() pages are output, they go on a page such as admin/help/link. Assuming a configuration like in the Standard install profile, with Seven theme and the usual blocks, the page structure has an H1 at the top for the page title, and then in the main content region, the next header is the H3 saying "About". There is no H2 on the page, except in the Toolbar area, which is outside the hierarchy of the main content region.

However, in order to follow best practices for accessibility, Techniques for WCAG 2.0: organizing a Page Using headings, sections should begin with an h2 and subsections an h3.

To facilitate navigation and understanding of overall document structure, authors should use headings that are properly nested (e.g., h1 followed by h2, h2 followed by h2 or h3, h3 followed by h3 or h4, etc.).

Proposed resolution

Update the following on the Help Text Standards documentation:

Documentation changes

1. Help page

Add a 'Headings' section.

2. ">Help Topic Standards

Add a link to the 'Heading' section that is added in 1 to the Help Topic Syntax Example.

Current text
Proposed text

Headings

  • Use an h2 element to indicate major sections of your help page.
  • Should your sections contain subsections, Use an h3 element to indicate each subsection.
  • Do not skip heading levels. An h2 should be followed by another h2, or an h3.

Remaining tasks

Update proposal to include Help Topic standards, #22

  • Update Help Text Standards documentation.
  • Then patch Drupal core, at least, to change the headings to H2 in the modules' implementations of hook_help(). #3414263: Change help headings for WCAG 2.0
  • A change record, noting hook_help() now uses improved heading levels, and encouraging contrib/custom module maintainers to do the same.

Coder changes

1. Link to Coder issue

Comments

RachelOlivero created an issue. See original summary.

jhodgdon’s picture

Some additional information:

a) These standards are used for modules that implement hook_help().

b) Normally, this help is displayed on a page like
admin/help/link (for the Link module)
where, in the Seven theme, there is an H1 at the top for the page title ("Link"), and then in the main content region, the next header is the H3 saying "About". There is no H2 on the page, except in the Toolbar area, which is outside the hierarchy of the main content region.

c) The standards have been in place with a suggestion of an H3 for About, and an H3 for Uses, for about 9 years. They were adopted as "way better than what came before" (which was no headings at all, and no standard structure), without much discussion of the details of the struture, on this issue:
#537828: Help text for core modules - update to conform to new standard

I'll add these notes to the issue summary.

jhodgdon’s picture

I am +1 for this change by the way.

andrewmacpherson’s picture

Issue summary: View changes

Thanks for filing this, great issue summary.

After we update core modules hook_help(), a change record should explain this, and encourage contrib/custom modules to update theirs too.

andrewmacpherson’s picture

Status: Active » Needs review
StatusFileSize
new4.24 KB

So we can see how the proposed headings work out, this patch replaces H3 with H2 in hook_help() for modules beginning with A.

andrewmacpherson’s picture

@jhodgdon - I see this issue is in coding standards project, but core patches would need to be against the drupal core project. Should we have a separate issue for the core patch? If we update the documentation page first, we could move this issue to the drupal core project afterwards.

andrewmacpherson’s picture

StatusFileSize
new490 bytes
new4.84 KB
new120.06 KB
new120.47 KB

One interesting thing I noticed is that some module help pages have a section for admin links. This list is generated automatically, and also has a H3.

This patch updates HelpController.php to make it use a H2 as well.

Before this patch:
Headings map for Actions module help page. Main content has H3 headings, which are children of the breadcrumb navigation H2.

After this patch:
Headings map for Actions module help page. Main content has H2 headings, which are siblings of the breadcrumb navigation H2.

jhodgdon’s picture

RE #6, the normal course of action for coding standards issues is:

a) Get the community to agree on the coding standards change. (There's a defined process for that -- see the Coding Standards project page and links therein. https://www.drupal.org/project/coding_standards )

b) Formally adopt the coding standards change and update the coding standards documentation for it.

c) File a new Core issue and patch for coding standards.

andrewmacpherson’s picture

Thanks, so the core patch will be a new issue. Meanwhile the patch in #7 at least demonstrates what we're proposing, but there's no need to finish it yet.

From the process:

At least two additional active community members (contrib module maintainers, active patch contributors, etc) need to agree to sponsor the change in the form of a comment on the issue.

Well it's +1 from me, then.

jhodgdon’s picture

OK, then we have 2 active community members with +1 on this. I'll post a link in a couple of Slack channels to get more discussion, and we should leave this for a week or two to get more input if people are interested, and then we can tag with "needs announcement for final discussion".

alexdmccabe’s picture

+1 from me!

jds1’s picture

This gets a +1 from me too! Looks like a great idea.

mgifford’s picture

This is great. What is needed to move this ahead?

jhodgdon’s picture

Issue tags: +needs announcement for final discussion

Well, let's see -- the procedure is here: https://www.drupal.org/project/coding_standards

So it looks like we have finished the first two steps: create and issue and find at least 2 active people in the community who support it. So I think we can do step 3 and add the "needs announcement for final discussion" tag. Let's do it!

mgifford’s picture

Issue tags: -Accessibility +accessibility

Ok, it looks like this is ready to go. We just need someone to make it happen. It's got the tag, how do we make it fixed?

mgifford’s picture

Issue tags: -accessibility (duplicate tag) +Accessibility

Fixing tagging.

neeravbm’s picture

I am in favor of this change. According to Coding Standards, we should have completed #5. I don't see any update on #6 yet. How do we move this forward?

aaronmchale’s picture

Issue tags: +DCScot19
sushma9’s picture

StatusFileSize
new19.88 KB

Added a patch for the heading change of help from h3 to h2 for below modules:

Action, Aggregator, AutomatedCron, Ban, Basic Auth, Big Pipe, Block, Block Place, Book, Breakpoint, CK Editor, Color

sushma9’s picture

StatusFileSize
new129.35 KB

This patch has got heading changes for all core modules

quietone’s picture

Issue summary: View changes

This was discussed at a coding standards meeting. #3380936: Coding Standards Meeting 2023-08-01 2100 UTC where the following points were raised.

I've updated the Issue Summary. In doing so I have removed two of the requested changes because that section of documentation, the example, was deleted. See https://www.drupal.org/node/632280/revisions/view/12277977/12369190

quietone’s picture

Issue summary: View changes
Status: Needs review » Needs work

I now see that there is wiki page for 'Help Topic Standards'. I think these changes should also go there. Or is there a better way to have the same information in two places?

Setting to NW

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review

Update the IS in preparation for announcing this one

andypost’s picture

This change is scriptable

core$ cat help.sh 
#!/bin/bash

# Path to the Drupal root directory.
DRUPAL_ROOT="/path/to/drupal"
DRUPAL_ROOT="."

# Function name pattern of hook implementations for hook_help.
HOOK_HELP_PATTERN='function .*_help'

# Find all files in the Drupal root directory.
find "$DRUPAL_ROOT" -type f -name "*.module" | while read -r file; do
    # Check if the file contains the implementation of hook_help.
    if grep -q "$HOOK_HELP_PATTERN" "$file"; then
        # Use sed to replace <h3> with <h2> in the hook_help implementation.
        sed -i "/${HOOK_HELP_PATTERN}/,/^}/{s/<h3>/<h2>/g; s/<\\/h3>/<\\/h2>/g;}" "$file"
        echo "Updated $file"
    fi
done

echo "Done replacing <h3> tags with <h2> in hook_help implementations."

larowlan’s picture

Issue tags: -Needs announcement for final discussion
quietone’s picture

Status: Needs review » Reviewed & tested by the community

This was discussed by the coding standards committee and we all agreed to do this.

I have updated the documentation per the issue summary.

quietone’s picture

Project: Coding Standards » Drupal core
Version: » 11.x-dev
Component: Coding Standards » help.module
Category: Feature request » Task

We also agreed that this isn't a Coding Standards issue, so moving to the Core queue.

quietone’s picture

quietone credited longwave.

quietone’s picture

Adding credit for the discussion amongst some coding standing committee members.

longwave’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

The patches are woefully out of date, please open a merge request instead and let's work on this against 11.x there.

longwave’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll

Oh I see, we are scripting the changes instead. But if we are doing that in another issue, what's this issue for - only updating docs?

longwave’s picture

Hiding the patches so they don't confuse others like they did to me.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work

The Needs Review Queue Bot tested this issue.

While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

quietone’s picture

Issue summary: View changes
Issue tags: +Needs change record

Yes, this is about documentation.

On reflection, the change record should be on this issue as it is the changing the Standards documentation.

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record

I added a change record here.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Thank you, back to RTBC

quietone’s picture

Status: Reviewed & tested by the community » Fixed

@andypost, thank you!

The documentation is updated and the implementation issue is also complete. The remaining piece is to publish the CR and set this to Fixed. I double checked the docs and the CR and I don't see anything that needs to be changed. Since there has been no further feedback and even though I wrote the CR I am going to publish and set this to Fixed.

Thank you to everyone here for improving Drupal!

Status: Fixed » Closed (fixed)

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