Skip to content

Commit d476917

Browse files
committed
Add --no-highlight option
Part of #232.
1 parent 01c2daf commit d476917

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

build.sh

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ WATTSI_LATEST=90
1616
LOCAL_WATTSI=true
1717
DO_UPDATE=true
1818
DO_LINT=true
19+
DO_HIGHLIGHT=true
1920
USE_DOCKER=false
2021
VERBOSE=false
2122
QUIET=false
@@ -128,12 +129,13 @@ function processCommandLineArgs {
128129
echo " $0 help Show this usage statement."
129130
echo
130131
echo "Build options:"
131-
echo " -d|--docker Use Docker to build in a container."
132-
echo " -s|--serve After building, serve the results on http://localhost:$SERVE_PORT."
133-
echo " -n|--no-update Don't update before building; just build."
134-
echo " -l|--no-lint Don't lint before building; just build."
135-
echo " -q|--quiet Don't emit any messages except errors/warnings."
136-
echo " -v|--verbose Show verbose output from every build step."
132+
echo " -d|--docker Use Docker to build in a container."
133+
echo " -s|--serve After building, serve the results on http://localhost:$SERVE_PORT."
134+
echo " -n|--no-update Don't update before building; just build."
135+
echo " -l|--no-lint Don't lint before building; just build."
136+
echo " -h|--no-highlight Don't syntax-highlight the output."
137+
echo " -q|--quiet Don't emit any messages except errors/warnings."
138+
echo " -v|--verbose Show verbose output from every build step."
137139
exit 0
138140
;;
139141
-n|--no-update|--no-updates)
@@ -142,6 +144,9 @@ function processCommandLineArgs {
142144
-l|--no-lint)
143145
DO_LINT=false
144146
;;
147+
-h|--no-highlight)
148+
DO_HIGHLIGHT=false
149+
;;
145150
-d|--docker)
146151
USE_DOCKER=true
147152
;;
@@ -196,16 +201,20 @@ function checkHTMLBuildIsUpToDate {
196201
# Tries to install the bs-highlighter Python package if necessary
197202
# - Arguments: none
198203
# - Output:
199-
# - Either bs-highlighter-server will be in the $PATH, or a warning will be echoed
204+
# - Either bs-highlighter-server will be in the $PATH, or $DO_HIGHTLIGHT will be set to false and
205+
# a warning will be echoed.
200206
function ensureHighlighterInstalled {
201207
# If we're not using local Wattsi then we won't use the local highlighter.
202-
if [[ $LOCAL_WATTSI == "true" ]]; then
208+
if [[ $LOCAL_WATTSI == "true" && $DO_HIGHLIGHT == "true" ]]; then
203209
if hash pip3 2>/dev/null; then
204210
if ! hash bs-highlighter-server 2>/dev/null; then
205211
pip3 install bs-highlighter
206212
fi
207213
else
208-
LOCAL_WATTSI="false"
214+
echo
215+
echo "Warning: could not find pip3 in your PATH. Disabling syntax highlighting."
216+
echo
217+
DO_HIGHLIGHT="false"
209218
fi
210219
fi
211220
}
@@ -430,6 +439,7 @@ function doDockerBuild {
430439
$VERBOSE && DOCKER_RUN_ARGS+=( --verbose )
431440
$DO_UPDATE || DOCKER_RUN_ARGS+=( --no-update )
432441
$DO_LINT || DOCKER_RUN_ARGS+=( --no-lint )
442+
$DO_HIGHLIGHT || DOCKER_RUN_ARGS+=( --no-highlight )
433443
$SERVE && DOCKER_RUN_ARGS+=( --serve )
434444

435445
# Pass in the html-build SHA (since there's no .git directory inside the container)
@@ -609,15 +619,18 @@ function checkWattsi {
609619
function runWattsi {
610620
clearDir "$2"
611621

612-
WATTSI_ARGS=()
613-
if $QUIET; then
614-
WATTSI_ARGS+=( --quiet )
615-
fi
616-
WATTSI_ARGS+=( "$1" "$HTML_SHA" "$2" "$BUILD_TYPE" \
617-
"$HTML_CACHE/caniuse.json" \
618-
"$HTML_CACHE/mdn-spec-links-html.json" \
619-
"$HIGHLIGHT_SERVER_URL" )
620622
if [[ "$LOCAL_WATTSI" == "true" ]]; then
623+
WATTSI_ARGS=()
624+
if $QUIET; then
625+
WATTSI_ARGS+=( --quiet )
626+
fi
627+
WATTSI_ARGS+=( "$1" "$HTML_SHA" "$2" "$BUILD_TYPE" \
628+
"$HTML_CACHE/caniuse.json" \
629+
"$HTML_CACHE/mdn-spec-links-html.json" )
630+
if [[ "$DO_HIGHLIGHT" == "true" ]]; then
631+
WATTSI_ARGS+=( "$HIGHLIGHT_SERVER_URL" )
632+
fi
633+
621634
WATTSI_RESULT="0"
622635
wattsi "${WATTSI_ARGS[@]}" || WATTSI_RESULT=$?
623636
else
@@ -681,7 +694,7 @@ function generateBacklinks {
681694
# - A server will be running in the background, at $HIGHLIGHT_SERVER_URL
682695
# - $HIGHLIGHT_SERVER_PID will be set for later use by stopHighlightServer
683696
function startHighlightServer {
684-
if [[ "$LOCAL_WATTSI" == "true" ]]; then
697+
if [[ "$LOCAL_WATTSI" == "true" && "$DO_HIGHLIGHT" == "true" ]]; then
685698
HIGHLIGHT_SERVER_ARGS=()
686699
$QUIET && HIGHLIGHT_SERVER_ARGS+=( --quiet )
687700
bs-highlighter-server ${HIGHLIGHT_SERVER_ARGS[@]+"${HIGHLIGHT_SERVER_ARGS[@]}"} &

0 commit comments

Comments
 (0)