Update Help Text Standards Examples to Modify Heading Structure

Created on 17 April 2018, about 6 years ago
Updated 16 February 2024, 5 months ago

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 β†’ .

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(). πŸ“Œ Change help headings for WCAG 2.0 Active
  • 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

πŸ“Œ Task
Status

Fixed

Version

11.0 πŸ”₯

Component
HelpΒ  β†’

Last updated 26 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States RachelOlivero

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • Documentation

    Primarily changes documentation, not code. For Drupal core issues, select the Documentation component instead of using this tag. In general, component selection is preferred over tag selection.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

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

    • This is referring to hook_help which is intended to be deprecated, 🌱 Deprecate hook_help() and combine with Topics Active .
    • Should the Help Topic standards be withing the Coding standard wiki pages. What is the history for having them separate? Should they be moved?

    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 β†’

  • Status changed to Needs work 11 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    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

  • Status changed to Needs review 10 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    Update the IS in preparation for announcing this one

  • πŸ‡«πŸ‡·France andypost

    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."
    
    
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10
  • Status changed to RTBC 6 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

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

    I have updated the documentation per the issue summary.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

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

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    The followup to make the change is πŸ“Œ Change help headings for WCAG 2.0 Active

  • πŸ‡¬πŸ‡§United Kingdom longwave UK
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

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

  • Status changed to Needs work 6 months ago
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

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

  • Status changed to RTBC 6 months ago
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    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?

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

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

  • Status changed to Needs work 6 months ago
  • 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.)

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    Yes, this is about documentation.

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

  • Status changed to Needs review 6 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    I added a change record here.

  • Status changed to RTBC 6 months ago
  • πŸ‡«πŸ‡·France andypost

    Thank you, back to RTBC

  • Status changed to Fixed 5 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    @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 her for improving Drupal!

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

Production build 0.69.0 2024