-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
180 lines (141 loc) · 5.99 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
MAKE ?= make
PIP ?= pip3
PORT ?= 8000
TMPTAGDIR := .tmptags
IGNORED := "shareLocation|splitChord|chord|bembel|merge|port|shortFermata|color|colour|symbol|unit"
MKDIR := mkdocs
DOCDIR := $(MKDIR)/docs
TAGSDEST := $(DOCDIR)/refs/tags
GUIDODIR ?= ../guidolib
SRCDIR := $(GUIDODIR)/src/engine
INLINEGMN := $(wildcard examples/mkdocs/*.gmn)
INLINEHTML := $(INLINEGMN:examples/mkdocs/%.gmn=$(DOCDIR)/GMN/%.html)
GMNEXAMPLES := $(wildcard examples/mkdocs/examples/*.gmn)
HTMLEXAMPLES:= $(GMNEXAMPLES:examples/mkdocs/examples/%.gmn=$(DOCDIR)/GMN/examples/%.html)
MDEXAMPLES := $(GMNEXAMPLES:examples/mkdocs/examples/%.gmn=$(DOCDIR)/examples/%.md)
EXAMPLESMENU:= $(MDEXAMPLES:%.md=%.item)
EDITOR := https://guidoeditor.grame.fr/
.PHONY: tagslist.txt
####################################################################
help:
@echo "======================================================="
@echo " Guido Music Notation format"
@echo "This Makefile is intended to generate the documentation"
@echo "======================================================="
@echo "Available targets are:"
@echo " install : install the required components"
@echo " build : build the web site"
@echo " serve : launch the mkdoc server"
@echo " all : generates all the necessary files from the src code or from gmn files"
@echo " actually call the 'tagfiles', 'tagsindex', 'gmn' and 'zip' targets"
@echo "Development specific targets are available:"
@echo " tagfiles : create the tags documention md files from the src files"
@echo " tagsindex: generates the tags index page"
@echo " gmn : call inlinegmn and examples targets"
@echo " inlinegmn: process the inline gmn files"
@echo " examples : process the gmn examples files"
@echo " menu : generates the examples menu"
@echo " zip : create a zip file with all examples at the appropriate location"
@echo " gmnclean : remove the output of the gmn target"
@echo "Making the current version publicly available:"
@echo " publish : make all + build"
test:
@echo EXAMPLESMENU: $(EXAMPLESMENU)
####################################################################
build:
cd $(MKDIR) && mkdocs build
git checkout docs/CNAME
serve:
cd $(MKDIR) && mkdocs serve -a 127.0.0.1:$(PORT)
git checkout docs/CNAME
all:
$(MAKE) tagfiles
$(MAKE) tagsindex
$(MAKE) gmn
$(MAKE) zip
cp -r Introduction $(DOCDIR)
publish:
$(MAKE) all
$(MAKE) build
@echo "Site is in docs folder: review the changes, add new files, commit and push manually"
####################################################################
# building guido examples
gmn:
$(MAKE) inlinegmn
$(MAKE) examples
inlinegmn: $(INLINEHTML)
examples : $(MDEXAMPLES) $(HTMLEXAMPLES)
examplesmd : $(MDEXAMPLES)
exampleshtml : $(HTMLEXAMPLES)
gmnclean:
rm -f $(INLINEHTML) $(MDEXAMPLES) $(HTMLEXAMPLES)
menu: $(EXAMPLESMENU)
zip:
@[ -d $(DOCDIR)/rsrc ] || mkdir $(DOCDIR)/rsrc
cd examples/mkdocs && zip -r examples examples
mv examples/mkdocs/examples.zip $(DOCDIR)/rsrc
####################################################################
tagfiles: $(GUIDODIR)
@rm -rf $(TMPTAGDIR)
@[ -d $(TMPTAGDIR) ] || mkdir $(TMPTAGDIR)
awk -v OUT=$(TMPTAGDIR) -f scripts/maketag.awk $(SRCDIR)/abstract/AR*.h
@[ -d $(TAGSDEST) ] || mkdir $(TAGSDEST)
mv -f $(TMPTAGDIR)/*.md $(TAGSDEST)
tagslist:
$(MAKE) -C $(GUIDODIR)/build/ tags | egrep -v 'make|grep' | egrep -v $(IGNORED) | grep -v ^s$ | sort -u
$(GUIDODIR):
@echo "GUIDODIR not found !"
@echo "you should either:"
@echo " - set GUIDODIR to the guidolib projet location in this Makefile"
@echo " - call $(MAKE) GUIDODIR=guidolib_projet_path"
@false;
chapters:
cat tags.txt | cut -d':' -f 2 | sort -u
tagschapters:
cat tags.txt | sed -e 's/\([^:]*\):\([^:]*\)/\2:\1/' | sed 's/ *//g' | sort -u
tagsindex: $(DOCDIR)/refs/index.md
$(DOCDIR)/refs/index.md: Tags.txt
cat Tags.txt | awk -f scripts/tagslist.awk > $(DOCDIR)/refs/index.md
####################################################################
# rules to convert gmn to html
$(DOCDIR)/GMN/examples/%.html: examples/mkdocs/examples/%.gmn
@[ -d $(DOCDIR)/GMN/examples ] || mkdir $(DOCDIR)/GMN/examples
sh scripts/guido2svg.sh $< > $@
$(DOCDIR)/GMN/notes.html: examples/mkdocs/notes.gmn
$(eval b64 := $(shell openssl base64 -in $< | tr -d '\n'))
@echo '<button class="try_it" onclick=window.open("$(EDITOR)?code=$(b64)")> Try it online </button>' > $@
@echo '<div class="guido-code guido-medium">' >> $@
@echo >> $@
guido2svg $< >> $@
@echo '</div>' >> $@
$(DOCDIR)/GMN/%.html: examples/mkdocs/%.gmn
$(eval b64 := $(shell openssl base64 -in $< | tr -d '\n'))
@echo '<button class="try_it" onclick=window.open("$(EDITOR)?code=$(b64)")> Try it online </button>' > $@
@echo '<div class="guido-code">' >> $@
@echo >> $@
guido2svg $< >> $@
@echo '</div>' >> $@
$(DOCDIR)/examples/%.md: examples/mkdocs/examples/%.gmn
@[ -d $(DOCDIR)/examples ] || mkdir $(DOCDIR)/examples
$(eval name := $(patsubst $(DOCDIR)/examples/%.md, %, $@))
awk -v FILE=$(name) -f scripts/sample2md.awk $< > $@
####################################################################
# rules to convert gmn to base 64
%.b64.txt : %.gmn
openssl base64 -in $< | tr -d '\n' > $@
####################################################################
# rule to generate the example menu items
$(DOCDIR)/examples/%.item : $(DOCDIR)/examples/%.md
$(eval file := $(patsubst $(DOCDIR)/examples/%.item, %, $@))
@echo " - '$(shell egrep '^# ' $< | sed 's/# *//' | sed 's/ *$$//')': examples/$(file).md"
####################################################################
install:
$(PIP) install mkdocs
$(PIP) install markdown-include
# npm i railroad-diagrams
upgrade:
$(PIP) install mkdocs --upgrade
$(PIP) install markdown-include --upgrade
uninstall:
$(PIP) uninstall -y markdown-include
$(PIP) uninstall -y mkdocs