-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkDocs.sh
executable file
·80 lines (66 loc) · 2.64 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
#!/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/generated-docs || echo "target/generated-docs exists") \
&& (mkdir /opt/maven/target/generated-docs/typescript-doc || echo "target/generated-docs/typescript-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/openapi.json",type=bind,ro \
--mount dst=/output,src="$PWD/target/tmp/typescript-fetch",type=bind \
gisaia/swagger-codegen-3.0.42 \
-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)'
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'
echo "=> Generate API documentation"
docker run --rm \
-v $PWD:/opt/maven \
-v $HOME/.m2:/root/.m2 \
busybox \
sh -c 'cat /opt/maven/docs/api/reference.md > /opt/maven/target/generated-docs/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-permissions.md'
echo "=> Check generated documentation"
if [[ ! -f ${BASEDIR}/target/generated-docs/typescript-doc/classes/AuthorizeApi.md ]] ; then
echo 'File "AuthorizeApi.md" was not generated, aborting.'
exit -1
fi
if [[ ! -f ${BASEDIR}/target/generated-docs/reference.md ]] ; then
echo 'File "reference.md" was not generated, aborting.'
exit -1
fi