forked from openthc/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
220 lines (171 loc) · 4.82 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#
# OpenTHC API Makefile
#
#
# Help, the default target
help:
@echo
@echo "You must supply a make command"
@echo
@grep --null-data --only-matching --perl-regexp "#\n#.*\n[\w\-]+:.*\n" $(MAKEFILE_LIST) \
| awk '/[a-zA-Z0-9_-]+:/ { printf " \033[0;49;32m%-20s\033[0m%s\n", $$1, gensub(/^# /, "", 1, x) }; { x=$$0 }' \
| sort
@echo
#
# Install necessary stuff
install:
apt-get -qy update
apt-get -qy upgrade
apt-get -qy install doxygen graphviz libyaml-dev
# http://pecl.php.net/package/yaml
pecl install yaml-1.3.1
echo "extension=yaml.so" > /etc/php5/mods-available/yaml.ini
php5enmod yaml
gem install asciidoctor-diagram coderay pygments.rb
gem install asciidoctor-pdf --pre
#
# All the things
all: code-swagger docs
#
# Build a bunch of docs
docs: docs-asciidoc docs-doxygen docs-swagger
#
# Generate asciidoc formats
docs-asciidoc:
asciidoctor \
--verbose \
--backend=html5 \
--require=asciidoctor-diagram \
--section-numbers \
--out-file=./webroot/doc/index.html \
./doc/index.ad
asciidoctor \
--verbose \
--backend=pdf \
--require=asciidoctor-diagram \
--require=asciidoctor-pdf \
--section-numbers \
--out-file=./doc/openthc-api.pdf \
./doc/index.ad
mv ./doc/openthc-api.pdf ./webroot/doc/openthc-api.pdf
# asciidoc \
# --backend=html5 \
# --out-file=./webroot/doc/index-alt.html \
# ./doc/index.ad
#
# asciidoc \
# --conf-file=./etc/asciidoc.conf \
# --backend=html5 \
# --out-file=./webroot/doc/index-cool.html \
# ./doc/index.ad
#
# asciidoc \
# --backend=slidy \
# --out-file=./webroot/doc/slides.html \
# ./doc/index.ad
#
# Magic with revealjs
docs-asciidoctor-reveal:
bundle config --local github.https true
bundle --path=.bundle/gems --binstubs=.bundle/.bin
bundle exec asciidoctor-revealjs -a revealjsdir=https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.7.0 ./doc/index.ad
#
# Generate Doxygent stuff
docs-doxygen:
doxygen etc/Doxyfile
#
# Build the Swagger docs (/doc/swagger-ui/dist)
docs-swagger:
# rm -fr ./webroot/doc/swagger
# rm -fr ./webroot/doc/swagger-ui
# git clone https://github.com/swagger-api/swagger-ui.git ./webroot/doc/swagger-ui/
#cd ./webroot/doc/swagger-ui/ && git pull || true
# mkdir ./webroot/doc/swagger/
# cp -a ./doc/swagger ./webroot/doc/
echo "# --- Generated File ---" > ./swagger.yaml
php ./bin/swagger-build.php >> ./swagger.yaml
mv ./swagger.yaml ./webroot/doc/swagger.yaml
# #
# rm -fr ./webroot/doc/swagger-html
# java -jar swagger-codegen-cli.jar \
# generate \
# --input-spec ./webroot/doc/swagger.yaml \
# --lang html \
# --output ./webroot/doc/swagger-html || true
#
# #
# rm -fr ./webroot/doc/swagger-html2
# java -jar swagger-codegen-cli.jar \
# generate \
# --input-spec ./webroot/doc/swagger.yaml \
# --lang html2 \
# --output ./webroot/doc/swagger-html2 || true
#
# Generate JSON Schema Files from swagger
code-json-schema: docs-swagger
# Building Schemas
# The files in this repo are constructed from the components in the API project.
rm -f ./json-schema/openthc/*json
python \
/opt/openapi2jsonschema/openapi2jsonschema/command.py \
--output ./json-schema/openthc/ \
--stand-alone \
webroot/doc/swagger.yaml
# file:/opt/api.openthc.org/webroot/doc/swagger.yaml
# cd ./webroot/json-schema ; ls *json > index.txt
#
# https://github.com/swagger-api/swagger-codegen
# Generate Swagger Docs
code-swagger: code-swagger-php docs-swagger
rm -fr ./webroot/sdk/bash
java -jar swagger-codegen-cli.jar \
generate \
--input-spec ./doc/swagger.yaml \
--lang bash \
--output ./webroot/sdk/bash || true
#rm -fr ./webroot/sdk/javascript
#rm -fr ./webroot/sdk/javascript.zip
#
#java -jar swagger-codegen-cli.jar \
# generate \
# --input-spec ./doc/swagger.yaml \
# --lang javascript \
# --output ./webroot/sdk/javascript || true
rm -fr ./webroot/sdk/python
java -jar swagger-codegen-cli.jar \
generate \
--input-spec ./doc/swagger.yaml \
--lang python \
--output ./webroot/sdk/python || true
#zip -r ./webroot/sdk/python.zip ./webroot/sdk/python/
# https://generator.swagger.io/#!/Admin/get_account
# https://online.swagger.io/validator/debug?url=https://api.openthc.org/swagger.yaml
#
#
code-swagger-go:
rm -fr ./webroot/sdk/go
rm -fr ./webroot/sdk/go.zip
#java -jar swagger-codegen-cli.jar \
# generate \
# --input-spec ./doc/swagger.yaml \
# --lang go \
# --output ./webroot/sdk/go || true
#
#cd ./webroot/sdk && zip -r go.zip ./go/
#
# Update the PHP SDK
code-swagger-php: docs-swagger
rm -fr ./webroot/sdk/php
rm -fr ./webroot/sdk/php.zip
java -jar swagger-codegen-cli.jar \
generate \
--input-spec ./doc/swagger.yaml \
--lang php \
--output ./webroot/sdk/php || true
zip -r ./webroot/sdk/php.zip ./webroot/sdk/php/
test: phpunit
#
# Execute Unit Tests
phpunit:
./test/test.sh
# ./vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration test/phpunit.xml test/