Skip to content

Commit 766b33f

Browse files
authored
Add help target for Makefile that iterates targets with basic docstring (#19)
Uses a Make trick to add a help target to the Makefile that iterates targets with basic docstrings that are extracted from the line where the target is defined behind a double-hash like `##`: help: ## Print this message Invocation: $ make help help Print this message lint Run linter (standardrb) test Run test suite (Rspec) type-check Run type check with Steep We also make `help` the default invocation so running `make` with nothing else will print the same thing: $ make help Print this message lint Run linter (standardrb) test Run test suite (Rspec) type-check Run type check with Steep
1 parent 0579a72 commit 766b33f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
.DEFAULT_GOAL := help
2+
3+
# Looks at comments using ## on targets and uses them to produce a help output.
4+
.PHONY: help
5+
help: ALIGN=14
6+
help: ## Print this message
7+
@awk -F ': .*## ' -- "/^[^':]+: .*## /"' { printf "'$$(tput bold)'%-$(ALIGN)s'$$(tput sgr0)' %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
8+
19
.PHONY: lint
2-
lint: standardrb
10+
lint: standardrb ## Run linter (standardrb)
311

412
.PHONY: rspec
513
rspec: spec
@@ -21,7 +29,7 @@ steep:
2129
bundle exec steep check
2230

2331
.PHONY: test
24-
test: spec
32+
test: spec ## Run test suite (Rspec)
2533

2634
.PHONY: type-check
27-
type-check: steep
35+
type-check: steep ## Run type check with Steep

0 commit comments

Comments
 (0)