-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkDocs.sh
executable file
·98 lines (83 loc) · 3.77 KB
/
mkDocs.sh
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
#!/bin/bash
set -e
function clean_exit {
ARG=$?
echo "===> Exit stage ${STAGE} = ${ARG}"
exit $ARG
}
trap clean_exit EXIT
# GO TO PROJECT PATH
SCRIPT_PATH=`cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd`
cd ${SCRIPT_PATH}
# SWAGGER DOC
echo "=> Get swagger documentation"
docker run --rm \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
busybox \
sh -c '(mkdir /opt/maven/target || echo "target exists") \
&& (mkdir /opt/maven/target/tmp || echo "target/tmp exists") \
&& (mkdir /opt/maven/target/tmp/typescript-fetch || echo "target/tmp/typescript-fetch exists") \
&& (mkdir /opt/maven/target/tmp/python-api || echo "target/tmp/python-api exists") \
&& (mkdir /opt/maven/target/generated-docs || echo "target/generated-docs exists") \
&& (mkdir /opt/maven/target/generated-docs/typescript-doc || echo "target/generated-docs/typescript-doc exists") \
&& (mkdir /opt/maven/target/generated-docs/python-doc || echo "target/generated-docs/python-doc exists") \
&& (cp -r /opt/maven/docs/* /opt/maven/target/generated-docs)'
echo "=> Generate API"
docker run --rm \
--mount dst=/input/api.json,src="$PWD/openapi/swagger.json",type=bind,ro \
--mount dst=/output,src="$PWD/target/tmp/typescript-fetch",type=bind \
gisaia/swagger-codegen-2.4.14 \
-l typescript-fetch --additional-properties modelPropertyNaming=snake_case
echo "=> Generate Typescript client documentation"
docker run --rm \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
busybox \
sh -c '(cp /opt/maven/conf/npm/package-doc.json /opt/maven/target/tmp/typescript-fetch/package.json) \
&& (cp /opt/maven/conf/npm/tsconfig-build.json /opt/maven/target/tmp/typescript-fetch/tsconfig.json)'
echo "=> Generate Python API and its documentation"
docker run --rm \
--mount dst=/input/api.json,src="$PWD/openapi/swagger.json",type=bind,ro \
--mount dst=/input/config.json,src="$PWD/conf/swagger/python-config.json",type=bind,ro \
--mount dst=/output,src="$PWD/target/tmp/python-api",type=bind \
gisaia/swagger-codegen-2.4.14 \
-l python --type-mappings GeoJsonObject=object
BASEDIR=$PWD
cd ${BASEDIR}/target/tmp/typescript-fetch/
docker run -a STDERR --rm -i -v `pwd`:/docs gisaia/typedocgen:0.0.7 generatedoc api.ts
cd ${BASEDIR}
docker run --rm \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
busybox \
sh -c 'mv /opt/maven/target/tmp/typescript-fetch/typedoc_docs/* /opt/maven/target/generated-docs/typescript-doc'
docker run --rm \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
busybox \
sh -c 'mv /opt/maven/target/tmp/python-api/docs/* /opt/maven/target/generated-docs/python-doc'
echo "=> Generate API documentation"
docker run --rm \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
busybox \
sh -c 'cat /opt/maven/docs/api/overview.md > /opt/maven/target/generated-docs/persistence_reference.md \
&& cat /opt/maven/docs/api/paths.md >> /opt/maven/target/generated-docs/persistence_reference.md \
&& cat /opt/maven/docs/api/definitions.md >> /opt/maven/target/generated-docs/persistence_reference.md \
&& cat /opt/maven/docs/api/security.md >> /opt/maven/target/generated-docs/persistence_reference.md'
echo "=> Copy CHANGELOG.md"
docker run --rm \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
busybox \
sh -c 'cp /opt/maven/CHANGELOG.md /opt/maven/target/generated-docs/CHANGELOG_ARLAS-persistence.md'
echo "=> Check generated documentation"
if [[ ! -f ${BASEDIR}/target/generated-docs/typescript-doc/classes/PersistApi.md ]] ; then
echo 'File "PersistApi.md" was not generated, aborting.'
exit -1
fi
if [[ ! -f ${BASEDIR}/target/generated-docs/persistence_reference.md ]] ; then
echo 'File "persistence_reference.md" was not generated, aborting.'
exit -1
fi