-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
66 lines (53 loc) · 1.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
BIN = mdbook
GEN := $(shell which $(BIN) 2> /dev/null)
DOWNLOAD = https://github.com/rust-lang/mdBook/releases
PUBLISH_DIR = book
PORT = 5099
define BINARY_ERROR
No $(BIN) found in Path.
Download $(BIN) from $(DOWNLOAD).
endef
build:
ifndef GEN
$(error $(BINARY_ERROR))
endif
@echo " >> Rebuilding book ..."
@$(GEN) build
serve:
@bash -c "trap \"$(MAKE) serve-cleanup\" EXIT; $(GEN) serve -p $(PORT)"
serve-cleanup: book-init build
run: serve
clean:
@rm -f $(PUBLISH_DIR)/README.md
spell-check:
@for FILE in `find . -name "*.md"`; do \
RESULTS=$$(cat $$FILE | aspell -d en_GB --mode=markdown list | sort -u | sed -e ':a' -e 'N;$$!ba' -e 's/\n/, /g'); \
if [[ "$$RESULTS" != "" ]] ; then \
echo "Potential spelling errors in $$FILE:"; \
echo "$$RESULTS" | \
sed -e 's/^/ /'; \
echo; \
fi; \
done
add-word: WORD ?= ""
add-word:
@echo "*$(WORD)\n#" | aspell -a > /dev/null
add-words: WORDS ?= ""
add-words:
@echo "Adding words:"
@for WORD in `echo $(WORDS)| tr "," "\n"| tr "," "\n" | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$$//'`; \
do echo " $$WORD ..."; \
echo "*$$WORD\n#" | aspell -a > /dev/null; \
done
@echo
spell-suggest:
@for FILE in `find . -name "*.md"`; do \
RESULTS=$$(cat $$FILE | aspell -d en_GB --mode=markdown list | sort -u ); \
if [[ "$$RESULTS" != "" ]] ; then \
echo "Potential spelling errors in $$FILE:"; \
for WORD in $$RESULTS; do \
echo $$WORD| aspell -d en_GB pipe | tail -2|head -1 | sed -e 's/^/ /'; \
done; \
echo; \
fi; \
done