@@ -5,30 +5,38 @@ ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
55TOOLS_BIN_DIR ?= $(ROOT_DIR ) /tmp/bin
66export PATH := $(TOOLS_BIN_DIR ) :$(PATH )
77MDTOC_BINARY =$(TOOLS_BIN_DIR ) /mdtoc
8+ MISSPELL_BINARY =$(TOOLS_BIN_DIR ) /misspell
89
910.PHONY : help
1011help : # # Display this help.
11- @awk ' BEGIN { FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_0-9-]+ :.*##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
12+ @awk ' BEGIN { FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z0-9][a-zA-Z0-9_ -]* :.*##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
1213
1314.PHONY : clean
1415clean : # # Remove all generated files and directories.
1516 rm -rf $(TOOLS_BIN_DIR )
1617
1718# #@ Generating
1819
19- .PHONY : toc-update update-toc
20- toc-update update-toc : $(MDTOC_BINARY ) # # Update table of contents in markdown files.
20+ .PHONY : toc-update
21+ toc-update : $(MDTOC_BINARY ) # # Update table of contents in markdown files.
2122 @echo " Updating tables of contents..."
2223 find $(ROOT_DIR ) -name ' *.md' \
2324 -not -path " */tmp/*" \
2425 -not -name " MAINTAINERS.md" \
2526 -not -name " PULL_REQUEST_TEMPLATE.md" \
2627 | xargs $(MDTOC_BINARY ) --inplace --max-depth=5
2728
29+ .PHONY : spelling-update
30+ spelling-update : $(MISSPELL_BINARY ) # # Fix spelling errors in markdown files.
31+ @echo " Fixing spelling errors..."
32+ find $(ROOT_DIR ) -name ' *.md' \
33+ -not -path " */tmp/*" \
34+ | xargs $(MISSPELL_BINARY ) -w
35+
2836# #@ Checking
2937
30- .PHONY : toc-verify verify-toc
31- toc-verify verify-toc : $(MDTOC_BINARY ) # # Verify table of contents are up to date.
38+ .PHONY : toc-verify
39+ toc-verify : $(MDTOC_BINARY ) # # Verify table of contents are up to date.
3240 @echo " Checking table of contents..."
3341 find $(ROOT_DIR ) -name ' *.md' \
3442 -not -path " */tmp/*" \
@@ -39,6 +47,16 @@ toc-verify verify-toc: $(MDTOC_BINARY) ## Verify table of contents are up to dat
3947 exit 1 \
4048 )
4149
50+ .PHONY : spelling-verify
51+ spelling-verify : $(MISSPELL_BINARY ) # # Verify spelling in markdown files.
52+ @echo " Checking spelling..."
53+ find $(ROOT_DIR ) -name ' *.md' \
54+ -not -path " */tmp/*" \
55+ | xargs $(MISSPELL_BINARY ) -error || ( \
56+ echo " Spelling errors found. Did you run 'make spelling-update'?" ; \
57+ exit 1 \
58+ )
59+
4260# #@ Dependencies
4361
4462.PHONY : tidy
@@ -51,6 +69,6 @@ tidy: ## Tidy Go module dependencies.
5169$(TOOLS_BIN_DIR ) :
5270 mkdir -p $(TOOLS_BIN_DIR )
5371
54- $(MDTOC_BINARY ) : $(TOOLS_BIN_DIR )
72+ $(MDTOC_BINARY ) $( MISSPELL_BINARY ) : $(TOOLS_BIN_DIR )
5573 @echo " Installing tools from scripts/tools.go"
5674 @cd $(ROOT_DIR ) /scripts && GOBIN=$(TOOLS_BIN_DIR ) go install -mod=readonly -modfile=go.mod $$(cat tools.go | grep _ | awk -F'"' '{print $$2}' )
0 commit comments