Convention specification

Self-Documenting Help

make help is generated from ## comments on the targets themselves, so the list of commands cannot drift from the real ones.

Applies at
scripts/build/
Status
Stable

01 Defines

A convention for documenting make targets in place: a trailing ## description on a target line lists it in make help, and a ##@ Section line starts a group.

02 Applies when

  • Targets are spread across many make modules that are added and removed over time.
  • The first thing a newcomer runs should show what the repository can do.

03 Boundaries

  • Targets without a ## comment are internal and stay out of the listing.
  • The help module does not know about specific targets or repositories.

Expected behaviour

  1. 01
    help is the default goal, so a bare make prints it.
  2. 02
    Every public target carries a one-line ## description on its rule line.
  3. 03
    Each module opens its public targets with a ##@ Section heading.
  4. 04
    An optional HELP_START banner from repository.mk is printed first.
  5. 05
    Sections appear in module load order, because the help reads MAKEFILE_LIST.

Behaviour#

There is no hand-maintained list of commands. The help target runs awk over every makefile that make has loaded and picks out two kinds of line: section headings that start with ##@, and rule lines that end in ## description.

FlowFrom comments to help
  1. 01 Annotate A module writes doctor: ## Verify required tools ...
  2. 02 Load Make records every included file in MAKEFILE_LIST
  3. 03 Scan awk prints ##@ lines as headings and target: ## text as entries
  4. 04 Print HELP_START banner, then each section in load order

Because the source of the listing is the makefiles themselves, adding a module adds its section, and deleting one removes it. The help composes the same way the Make Module Registries do, without a registry of its own.

Examples#

scripts/build/10-help.mk
.DEFAULT_GOAL := help

.PHONY: help
help: ## List available targets with their descriptions
	@if [ -n "$(HELP_START)" ]; then printf '%s\n' "$(HELP_START)"; fi
	@awk 'BEGIN { FS = ":.*##" } \
	  /^##@/ { printf "\n%s\n", substr($$0, 5); next } \
	  /^[a-zA-Z0-9_.-]+:.*?##/ { printf "  %-28s %s\n", $$1, $$2 }' \
	  $(MAKEFILE_LIST)
	@printf '\n'

The beginning of the generated output in this repository:

Start here: make doctor (check tools), make check.hugo (build site), make help (all targets)
  help                          List available targets with their descriptions

Environment
  doctor                        Verify required tools and repository contracts are present
  config                        Show the explicit component configuration from repo config

Repository hygiene
  format                        Rewrite repository files to the canonical format

Connections

How Self-Documenting Help relates to the library

Self-Documenting Help and 1 related specificationsMake Module RegistriesMake Module Registries
RefinesComposesRelies onFollowed byContrasts with