-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMakefile
73 lines (58 loc) · 1.63 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
67
68
69
70
71
72
73
BIN = mdbook
GEN := $(shell which $(BIN) 2> /dev/null)
DOWNLOAD = https://github.com/rust-lang/mdBook/releases
PUBLISH_DIR = book
PUBLISH_CONTENT = $(PUBLISH_DIR)
PORT = 5099
default: build
define BINARY_ERROR
No $(BIN) found in Path.
Download $(BIN) from $(DOWNLOAD).
endef
build: clean-all
ifndef GEN
$(error $(BINARY_ERROR))
endif
@echo ">> Rebuilding book ..."
@$(GEN) build -d $(PUBLISH_CONTENT)
serve:
@echo ">> Preparing to run mdbook server ..."
@$(GEN) serve -p $(PORT) -d $(PUBLISH_CONTENT)
run: serve
clean:
@echo ">> Removing auto-generated top-level files ..."
clean-all: clean
@echo ">> Removing previously generated content ..."
@rm -rf $(PUBLISH_CONTENT)
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
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; \
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