Skip to content

Add experimental support to build using Bikeshed #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ html/
output/
mdn/.id-list
mdn/developer.mozilla.org/
node_modules/
highlighter/


Expand Down
74 changes: 50 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare -r WATTSI_LATEST=140
# Shared state variables throughout this script
LOCAL_WATTSI=true
WATTSI_RESULT=0
USE_BIKESHED=false
DO_UPDATE=true
DO_LINT=true
DO_HIGHLIGHT=true
Expand All @@ -37,6 +38,7 @@ HTML_GIT_CLONE_OPTIONS=${HTML_GIT_CLONE_OPTIONS:-"--depth=2"}

# This is used by child scripts, and so we export it
export HTML_CACHE
export USE_BIKESHED

# Used specifically when the Dockerfile calls this script
SKIP_BUILD_UPDATE_CHECK=${SKIP_BUILD_UPDATE_CHECK:-false}
Expand Down Expand Up @@ -85,14 +87,16 @@ function main {
exit 0
fi

checkWattsi
ensureHighlighterInstalled
if [[ $USE_BIKESHED != "true" ]]; then
checkWattsi
ensureHighlighterInstalled

doLint
doLint

updateRemoteDataFiles
updateRemoteDataFiles

startHighlightServer
startHighlightServer
fi

processSource "source" "default"

Expand Down Expand Up @@ -146,6 +150,7 @@ function processCommandLineArgs {
echo " $0 help Show this usage statement."
echo
echo "Build options:"
echo " -b|--bikeshed Use Bikeshed instead of Wattsi. (experimental)"
echo " -d|--docker Use Docker to build in a container."
echo " -r|--remote Use the build server."
echo " -s|--serve After building, serve the results on http://localhost:$SERVE_PORT."
Expand Down Expand Up @@ -176,6 +181,10 @@ function processCommandLineArgs {
DO_HIGHLIGHT=false
SINGLE_PAGE_ONLY=true
;;
-b|--bikeshed)
USE_BIKESHED=true
SINGLE_PAGE_ONLY=true
;;
-d|--docker)
USE_DOCKER=true
;;
Expand Down Expand Up @@ -663,34 +672,49 @@ function processSource {
cargo run "${cargo_args[@]}" <"$HTML_SOURCE/$source_location" >"$HTML_TEMP/source-whatwg-complete"
fi

runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
if [[ $WATTSI_RESULT == "0" ]]; then
if [[ $LOCAL_WATTSI != "true" ]]; then
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
if [[ $USE_BIKESHED == "true" ]]; then
clearDir "$HTML_TEMP/bikeshed-output"

# TODO: port to html-build Rust code
node wattsi2bikeshed.js "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/source-whatwg-complete.bs"

local bikeshed_args=( --force )
$DO_UPDATE || bikeshed_args+=( --no-update )
bikeshed "${bikeshed_args[@]}" spec "$HTML_TEMP/source-whatwg-complete.bs" "$HTML_TEMP/bikeshed-output/index.html" --md-Text-Macro="SHA $HTML_SHA" --md-Text-Macro="COMMIT-SHA $HTML_SHA"
else
if [[ $LOCAL_WATTSI != "true" ]]; then
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
if [[ $WATTSI_RESULT == "65" ]]; then
echo
echo "There were errors. Running again to show the original line numbers."
echo
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
if [[ $WATTSI_RESULT == "0" ]]; then
if [[ $LOCAL_WATTSI != "true" ]]; then
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
else
if [[ $LOCAL_WATTSI != "true" ]]; then
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
if [[ $WATTSI_RESULT == "65" ]]; then
echo
echo "There were errors. Running again to show the original line numbers."
echo
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
if [[ $LOCAL_WATTSI != "true" ]]; then
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
fi
echo
echo "There were errors. Stopping."
exit "$WATTSI_RESULT"
fi
echo
echo "There were errors. Stopping."
exit "$WATTSI_RESULT"
fi

# Keep the list of files copied from $HTML_SOURCE in sync with `doServerBuild`

if [[ $build_type == "default" ]]; then
# Singlepage HTML
mv "$HTML_TEMP/wattsi-output/index-html" "$HTML_OUTPUT/index.html"
if [[ $USE_BIKESHED == "true" ]]; then
mv "$HTML_TEMP/bikeshed-output/index.html" "$HTML_OUTPUT/index.html"
else
mv "$HTML_TEMP/wattsi-output/index-html" "$HTML_OUTPUT/index.html"
fi

if [[ $SINGLE_PAGE_ONLY == "false" ]]; then
# Singlepage Commit Snapshot
Expand All @@ -706,7 +730,9 @@ function processSource {
fi

cp -p entities/out/entities.json "$HTML_OUTPUT"
cp -p "$HTML_TEMP/wattsi-output/xrefs.json" "$HTML_OUTPUT"
if [[ $USE_BIKESHED == "false" ]]; then
cp -p "$HTML_TEMP/wattsi-output/xrefs.json" "$HTML_OUTPUT"
fi

clearDir "$HTML_TEMP"

Expand Down
Loading