@@ -23,6 +23,12 @@ if ! [[ "${JQ}" ]]; then
23
23
exit 1
24
24
fi
25
25
26
+ GIT=$( command -v git)
27
+ if ! [[ " ${GIT} " ]]; then
28
+ echo " Command git not found. Please install git."
29
+ exit 1
30
+ fi
31
+
26
32
function ensure_docker_image() {
27
33
echo -n " Checking docker build image... "
28
34
local image=$( ${DOCKER} image ls | ${GREP} ${IMAGE_NAME} )
@@ -34,6 +40,21 @@ function ensure_docker_image() {
34
40
exit 1
35
41
}
36
42
43
+ function update_repositories() {
44
+ if [ ! -d ./scripts/sbcli-repo ]; then
45
+ echo " Cloning sbcli repository..."
46
+ git clone https://github.com/simplyblock-io/sbcli.git ./scripts/sbcli-repo
47
+ else
48
+ echo " Updating sbcli repository..."
49
+ pushd ./scripts/sbcli-repo
50
+ git reset --hard
51
+ git pull -f
52
+ local ret=$?
53
+ popd
54
+ exit ${ret}
55
+ fi
56
+ }
57
+
37
58
function build_image() {
38
59
docker build -t ${IMAGE_NAME} .
39
60
exit $?
@@ -45,6 +66,16 @@ function serve() {
45
66
exit $?
46
67
}
47
68
69
+ function gen_sbcli_ref() {
70
+ if [ ! -d ./scripts/sbcli-repo ]; then
71
+ echo " The sbcli repository not yet available. Please run ./doc-builder update-sbcli and try again."
72
+ exit 1
73
+ fi
74
+
75
+ echo " Generating sbcli reference pages..."
76
+ ${DOCKER} run --rm ${terminal} -v " ${PWD} " :/docs --entrypoint=" /usr/local/bin/python" ${IMAGE_NAME} /docs/scripts/cli-reference-gen.py /docs
77
+ }
78
+
48
79
function build() {
49
80
ensure_docker_image
50
81
echo -n " Cleaning site directory... "
@@ -57,8 +88,10 @@ function build() {
57
88
terminal=" -t"
58
89
fi
59
90
60
- echo " Generating CLI reference pages..."
61
- ${DOCKER} run --rm ${terminal} -v " ${PWD} " :/docs --entrypoint=" /usr/local/bin/python" ${IMAGE_NAME} /docs/scripts/cli-reference-gen.py /docs
91
+ # Generates the markdown files for the sbcli reference pages
92
+ if ! gen_sbcli_ref; then
93
+ exit 1
94
+ fi
62
95
63
96
echo " Building documentation... "
64
97
if ! ${DOCKER} run --rm ${terminal} -v " ${PWD} :/docs" ${IMAGE_NAME} build --strict " $@ " ; then
@@ -135,10 +168,20 @@ case "$1" in
135
168
deploy " ${@: 2} "
136
169
;;
137
170
171
+ " update-repositories" )
172
+ update_repositories
173
+ ;;
174
+
175
+ " gen-sbcli-ref" )
176
+ gen_sbcli_ref
177
+ ;;
178
+
138
179
* )
139
180
echo " Simplyblock Documentation Builder"
140
181
echo " Available commands:"
141
182
echo " ./doc-builder build-image Building required docker image"
183
+ echo " ./doc-builder update-repositories Initialized or updated external repository"
184
+ echo " ./doc-builder gen-sbcli-ref Generates the sbcli reference pages"
142
185
echo " ./doc-builder serve Live serving content changes"
143
186
echo " ./doc-builder build Building static documentation"
144
187
echo " ./doc-builder deploy {version-name} Preparing new version deployment "
0 commit comments