-
-
Notifications
You must be signed in to change notification settings - Fork 248
/
Makefile
80 lines (61 loc) · 2.57 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
74
75
76
77
78
79
80
-include Makefile.local # for optional local config
OUTPUT_DIR ?= ./site ## Build directory (default: ./site)
MKDOCS ?= mkdocs
DOCS_FILES := $(shell find docs -type f)
.PHONY: build
build: ## Build website into build directory
build: $(OUTPUT_DIR)
$(OUTPUT_DIR): $(DOCS_FILES) mkdocs.yml
$(MKDOCS) build -d $(OUTPUT_DIR) --strict
.PHONY: serve
serve: ## Run live-preview server
serve: mkdocs.yml
$(MKDOCS) serve
.PHONY: vendor
vendor: ## Install assets from external sources
vendor: carcin-play codemirror ansi_up
.PHONY: carcin-play
carcin-play: docs/assets/vendor/carcin-play/carcin.js docs/assets/vendor/carcin-play/carcin-play.js docs/assets/vendor/carcin-play/carcin-play.css docs/assets/vendor/carcin-play/codemirror-theme.css
docs/assets/vendor/carcin-play/%:
mkdir -p $(@D)
curl -sL -o $@ https://github.com/straight-shoota/carcin-play/raw/master/$(@F)
.PHONY: codemirror
codemirror: docs/assets/vendor/codemirror/codemirror.min.css docs/assets/vendor/codemirror/codemirror.min.js docs/assets/vendor/codemirror/mode/crystal/crystal.min.js
docs/assets/vendor/codemirror/%:
mkdir -p $(@D)
curl -sL -o $@ https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/$(@F)
docs/assets/vendor/codemirror/mode/crystal/crystal.min.js:
mkdir -p $(@D)
curl -sL -o $@ https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/crystal/crystal.min.js
.PHONY: ansi_up
ansi_up: docs/assets/vendor/ansi_up/ansi_up.min.js
docs/assets/vendor/ansi_up/%:
mkdir -p $(@D)
curl -sL -o $@ https://cdn.jsdelivr.net/npm/[email protected]/$(@F)
.PHONY: clean
clean: ## Remove build directory
rm -rf $(OUTPUT_DIR)
.PHONY: clean_vendor
clean_vendor: ## Remove docs/assets/vendor directory
rm -rf docs/assets/vendor
.PHONY: clean_all
clean_all: clean clean_vendor
.PHONY: format_api_docs_links
format_api_docs_links:
echo $(DOCS_FILES) | xargs sed -i -E -e 's@\bhttps?://(www\.)?crystal-lang\.org/api/([0-9]+(\.[0-9]+)+|latest|master)/([^ )]+\.html)\b@https://crystal-lang.org/api/\4@g'
.PHONY: help
help: ## Show this help
@echo
@printf '\033[34mtargets:\033[0m\n'
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) |\
sort |\
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo
@printf '\033[34moptional variables:\033[0m\n'
@grep -hE '^[a-zA-Z_-]+ \?=.*?## .*$$' $(MAKEFILE_LIST) |\
sort |\
awk 'BEGIN {FS = " \\?=.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo
@printf '\033[34mrecipes:\033[0m\n'
@grep -hE '^##.*$$' $(MAKEFILE_LIST) |\
awk 'BEGIN {FS = "## "}; /^## [a-zA-Z_-]/ {printf " \033[36m%s\033[0m\n", $$2}; /^## / {printf " %s\n", $$2}'