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 1 commit
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
58 changes: 36 additions & 22 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,9 @@ function processCommandLineArgs {
DO_HIGHLIGHT=false
SINGLE_PAGE_ONLY=true
;;
-b|--bikeshed)
USE_BIKESHED=true
;;
-d|--docker)
USE_DOCKER=true
;;
Expand Down Expand Up @@ -663,27 +671,33 @@ 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
echo "BIKESHED!!!"
bikeshed spec --byos "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/bikeshed-output" --md-Text-Macro="SHA $HTML_SHA"
exit 0
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
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
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"
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`
Expand Down
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ mod rcdom_with_line_numbers;
mod represents;
mod tag_omission;

const BIKEPLATE: &str = "<pre class=metadata>
Group: WHATWG
H1: HTML
Shortname: html
Abstract: HTML is Bikeshed.
Indent: 1
</pre>";

#[tokio::main]
async fn main() -> io::Result<()> {
// This gives slightly prettier error-printing.
Expand All @@ -35,6 +43,12 @@ async fn run() -> io::Result<()> {
// Find the paths we need.
let cache_dir = path_from_env("HTML_CACHE", ".cache");
let source_dir = path_from_env("HTML_SOURCE", "../html");
let use_bikeshed_str = env::var_os("USE_BIKESHED");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd probably be less messy to use a --bikeshed command line arg.

let use_bikeshed = use_bikeshed_str.is_some_and(|s| s.eq_ignore_ascii_case("TRUE"));
if use_bikeshed {
eprintln!("BIKESHED MODE");
println!("{}", BIKEPLATE);
}

// Because parsing can jump around the tree a little, it's most reasonable
// to just parse the whole document before doing any processing. Even for
Expand Down