-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
76 lines (65 loc) · 2.21 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
# Build all documents and diagrams from spec/ into the build/
# output folder. Please read RELEASE.md for more details on
# publishing the documents.
#
# Assumes python3 is installed
# Assumes npm is installed
#
# Examples of usage:
# make all
# make a clean build
# make build
# build the documents and diagrams
# make clean
# clean the build directory
# make install
# Will install bikeshed and mermaid-cli globally
# spec/**.mmd -> build/**.svg
DIAGRAMS := $(wildcard spec/v2/diagrams/*.mmd)
DIAGRAMS := $(DIAGRAMS:spec/%.mmd=build/%.svg)
SOURCES := $(wildcard **.bs)
# Build rule for bikeshed documents
build/%.html: spec/%.bs
@echo Check release status and version
$(eval status := $(shell sed -n 's/^Text Macro: STATUS //p' $<))
$(eval version := $(shell sed -n 's/^Text Macro: VERSION //p' $<))
$(eval date := $(shell sed -n 's/^Text Macro: DATE //p' $<))
@echo Build the document
mkdir -p $(dir $@)
bikeshed --allow-nonlocal-files spec $< $@
@echo Set the status in the document
@if [ "$(status)" = "Release" ]; then \
echo "Release: add version to title"; \
mv -f $@ [email protected]; \
sed 's/<title>\(.*\)<\/title>/<title>\1 (Version $(version))<\/title>/g' [email protected] > $@; \
mv -f $@ [email protected]; \
sed 's/\(<h1 .*id="title">.*\)\(<\/h1>\)/\1 (Version $(version))\2/g' [email protected] > $@; \
elif [ "$(status)" = "Draft" ] || [ "$(status)" = "Consultation" ]; then \
echo "No release: add version-date to title"; \
mv -f $@ [email protected]; \
sed 's/<title>\(.*\)<\/title>/<title>\1 (Version $(version)-$(date))<\/title>/g' [email protected] > $@; \
mv -f $@ [email protected]; \
sed 's/\(<h1 .*id="title">.*\)\(<\/h1>\)/\1 (Version $(version)-$(date))\2/g' [email protected] > $@; \
else \
echo "No status can be found"; \
fi
mv -f $@ [email protected]; \
sed 's/\(<h2 .*id="profile-and-date">\).*\(<\/h2>\)/\1$(status)\2/g' [email protected] > $@; \
rm -f [email protected];
# Build rule for mermaid diagrams
build/%.svg: spec/%.mmd
mkdir -p $(dir $@)
mmdc -i $< -o $@ --theme default
all: clean build
install:
@echo Install Bikeshed
pip3 install bikeshed && bikeshed update
@echo Install Mermaid
npm list -g @mermaid-js/mermaid-cli || npm install -g @mermaid-js/mermaid-cli
clean:
rm -rf build
build: \
build/index.html \
build/v2/index.html \
build/faq/index.html \
$(DIAGRAMS)