-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
140 lines (112 loc) · 3.52 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/make -f
SHELL=bash
VERSION?=$(shell git describe --abbrev=8 --dirty --always)
PLANTUML_BIN?=plantuml
DATE?=`LC_ALL=en_US date "+%B %e, %Y"`
BUILD_DIR = build
OUT_DIR = output
APIV2_DIR = "../neofs-api"
APIV2_DOC_DIR = "20-api-v2"
CONTRACTS_DIR = "../neofs-contract"
CONTRACTS = $(shell echo "${CONTRACTS_DIR}/alphabet")
CONTRACTS_DOC_DIR = "06-blockchain"
PDF_NAME?= "neofs-spec-${VERSION}.pdf"
TEX_NAME?= "neofs-spec-${VERSION}.tex"
PARTS = $(shell find . -mindepth 2 -maxdepth 2 -type f -name '*.md' | sort)
PUMLS = $(shell find . -mindepth 3 -maxdepth 4 -type f -name '*.puml' -o -name '*.plantuml' | sort)
SVGS = $(shell find . -mindepth 3 -maxdepth 4 -type f -name '*.svg' | sort)
HTML_PIC = $(shell find . -mindepth 3 -maxdepth 3 ! -path './${OUT_DIR}/*' ! -path './${BUILD_DIR}/*' -type f -name '*.svg' -o -name '*.png' -o -name '*.jpg')
.PHONY: all pdf html site directories view clean pdf_file_name
all: pdf site
directories: $(OUT_DIR) $(BUILD_DIR)
pdf: $(OUT_DIR)/$(PDF_NAME)
pdf_file_name:
@echo $(PDF_NAME)
view:
type xdg-open >/dev/null 2>&1 && xdg-open $(OUT_DIR)/$(PDF_NAME) || open $(OUT_DIR)/$(PDF_NAME)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(OUT_DIR):
mkdir -p $(OUT_DIR)
$(OUT_DIR)/$(PDF_NAME): | directories
pandoc \
$(PARTS) \
-M date="$(DATE)" \
-M version="$(VERSION)" \
--template=templates/eisvogel.latex \
--default-image-extension=pdf \
-H templates/style.pandoc \
-F pandoc-crossref \
-F pandoc-plantuml \
-F pandoc-img-glob \
--toc \
--highlight-style pygments \
-o $(BUILD_DIR)/$(TEX_NAME) && \
latexmk -r 'templates/glossaries.latexmk' \
-pdflatex='xelatex %O %S' \
-outdir=$(BUILD_DIR) \
-pdf $(BUILD_DIR)/$(TEX_NAME) && \
mv $(BUILD_DIR)/$(PDF_NAME) $@
html: | directories
pandoc --no-highlight \
$(PARTS) \
-M date="$(DATE)" \
-M version="$(VERSION)" \
--default-image-extension=svg \
--from markdown+smart+yaml_metadata_block+auto_identifiers \
--to html5 \
-o $(OUT_DIR)/index.html
.ONESHELL:
pic:
@for img in ${HTML_PIC}
do
path=$$(grep -Po \".\*`basename $$img`.\"* ${OUT_DIR}/index.html | tr -d '\"') && \
mkdir -p `dirname ${OUT_DIR}/$$path` && \
cp $$img ${OUT_DIR}/$$path
done
.PHONY: puml2svg svg2pdf
.ONESHELL:
puml2svg:
@for img in ${PUMLS}
do
$(PLANTUML_BIN) -charset utf8 -tsvg $$img
done
.ONESHELL:
svg2pdf:
@for img in $(basename $(SVGS))
do
rsvg-convert -f pdf -o $${img}.pdf $${img}.svg
done
site: html pic
.PHONY: update_api update_api_v2
.ONESHELL:
update_api_v2:
@for f in `find ${APIV2_DIR} -type f -name '*.proto' -exec dirname {} \; | sort -u `;
do
echo "Documentation for $$(basename $$f)";
protoc \
--doc_opt=templates/apiv2-package.tmpl,$${f}.md \
--proto_path=${APIV2_DIR}:/usr/local/include \
--doc_out=${APIV2_DOC_DIR} $${f}/*.proto;
done
update_api: update_api_v2
.PHONY: update_contracts
.ONESHELL:
update_contracts:
@for f in `find ${CONTRACTS_DIR} -mindepth 3 -maxdepth 3 -type f ! -path '*/nns/*' -name 'contract.go' -exec dirname {} \; | sort -u `;
do
echo "Documentation for $$(basename $$f)";
gomarkdoc --template-file file=templates/contracts-file.tmpl \
--template-file package=templates/contracts-package.tmpl \
--template-file func=templates/contracts-func.tmpl \
--template-file doc=templates/contracts-doc.tmpl \
$$f > ${CONTRACTS_DOC_DIR}/03-$$(basename $$f).md
done
.PHONY: image docker_build
image:
docker build -t 'nspccdev/neofs-spec' .
docker/%:
docker run --rm -v `pwd`:/src -u `stat -c "%u:%g" .` nspccdev/neofs-spec:latest make $$(basename $@)
clean:
rm -rf $(BUILD_DIR)
rm -rf $(OUT_DIR)