forked from ng-dnd/ng-dnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docs.sh
executable file
·130 lines (107 loc) · 2.86 KB
/
build-docs.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
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
#!/bin/bash
usage () {
echo "usage: $0 [--full] [--fast] [--serve] [--serve-only] [--no-examples] [--port <default is 8080>]"
}
fail () {
echo "failed on: $@"
echo "exiting"
exit 1
}
serve() {
echo "serving ./out-docs/ on http://localhost:$PORT"
(cd ./out-docs && python3 -m http.server $PORT)
exit
}
SERVE=0
SERVE_ONLY=0
PORT=8080
NO_EXAMPLES=0
if [ -n "$TRAVIS" ]; then
SERVE=0
SERVE_ONLY=0
else
while [ "$1" != "" ]; do
case $1 in
-h | --help)
usage
exit
;;
--full)
TRAVIS_BRANCH=main
TRAVIS_PULL_REQUEST=false
;;
--fast)
TRAVIS_BRANCH="fast"
TRAVIS_PULL_REQUEST="fast"
;;
--serve)
SERVE=1
;;
--serve-only)
SERVE_ONLY=1
;;
--no-examples)
NO_EXAMPLES=1
;;
--port)
PORT=$2
shift
;;
*)
echo "ERROR: unknown parameter \"$1\""
usage
exit 1
;;
esac
shift
done
fi
if [ $SERVE_ONLY -eq 1 ]; then
serve
fi
DIR=$(dirname "$0")
output="$DIR/out-docs"
core="$DIR/packages/core"
sortable="$DIR/packages/sortable"
multi_backend="$DIR/packages/multi-backend"
examples="$DIR/packages/examples"
EXAMPLES_TASK="local-docs"
if [ "$TRAVIS" == "true" ]; then
EXAMPLES_TASK="gh-pages"
fi
# Now, if we're running travis, we only want to build docs on main proper.
# Anything less (e.g. PRs to main) and we can go faster by building in dev mode
# and ignoring the docs (which never fail basically).
# This saves about 1-2 minutes per non-main build.
if [ "$TRAVIS" == "true" ] && ([ "$TRAVIS_BRANCH" != "main" ] || [ "$TRAVIS_PULL_REQUEST" != "false" ]); then
echo "travis-ing $TRAVIS $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST"
(cd "$examples" && yarn run fast)
exit $?
fi
build() {
set -euxo pipefail
rm -rf out-docs
rm -rf "$core/documentation"
(cd "$core" && yarn run docs)
# move main docs into output
(mv "$core/documentation" "$output")
# build sortable docs
(cd "$sortable" && yarn run docs)
# move multi-backend into output
(mv "$sortable/documentation" "$output/sortable")
# build multi-backend docs
(cd "$multi_backend" && yarn run docs)
# move multi-backend into output
(mv "$multi_backend/documentation" "$output/multi-backend")
# build examples
[ $NO_EXAMPLES -ne 1 ] && (cd "$examples" && yarn run $EXAMPLES_TASK)
# move examples into output
[ $NO_EXAMPLES -ne 1 ] && (mv "$examples/dist/examples" "$output/examples")
: "built successfully"
}
if [ $SERVE -eq 1 ]; then
build
serve
else
build
fi