Skip to content

Commit 99077f5

Browse files
committed
Add experimental support to build using Bikeshed
1 parent a0a6276 commit 99077f5

File tree

2 files changed

+50
-22
lines changed

2 files changed

+50
-22
lines changed

build.sh

+36-22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ declare -r WATTSI_LATEST=140
1515
# Shared state variables throughout this script
1616
LOCAL_WATTSI=true
1717
WATTSI_RESULT=0
18+
USE_BIKESHED=false
1819
DO_UPDATE=true
1920
DO_LINT=true
2021
DO_HIGHLIGHT=true
@@ -37,6 +38,7 @@ HTML_GIT_CLONE_OPTIONS=${HTML_GIT_CLONE_OPTIONS:-"--depth=2"}
3738

3839
# This is used by child scripts, and so we export it
3940
export HTML_CACHE
41+
export USE_BIKESHED
4042

4143
# Used specifically when the Dockerfile calls this script
4244
SKIP_BUILD_UPDATE_CHECK=${SKIP_BUILD_UPDATE_CHECK:-false}
@@ -85,14 +87,16 @@ function main {
8587
exit 0
8688
fi
8789

88-
checkWattsi
89-
ensureHighlighterInstalled
90+
if [[ $USE_BIKESHED != "true" ]]; then
91+
checkWattsi
92+
ensureHighlighterInstalled
9093

91-
doLint
94+
doLint
9295

93-
updateRemoteDataFiles
96+
updateRemoteDataFiles
9497

95-
startHighlightServer
98+
startHighlightServer
99+
fi
96100

97101
processSource "source" "default"
98102

@@ -146,6 +150,7 @@ function processCommandLineArgs {
146150
echo " $0 help Show this usage statement."
147151
echo
148152
echo "Build options:"
153+
echo " -b|--bikeshed Use Bikeshed instead of Wattsi. (experimental)"
149154
echo " -d|--docker Use Docker to build in a container."
150155
echo " -r|--remote Use the build server."
151156
echo " -s|--serve After building, serve the results on http://localhost:$SERVE_PORT."
@@ -176,6 +181,9 @@ function processCommandLineArgs {
176181
DO_HIGHLIGHT=false
177182
SINGLE_PAGE_ONLY=true
178183
;;
184+
-b|--bikeshed)
185+
USE_BIKESHED=true
186+
;;
179187
-d|--docker)
180188
USE_DOCKER=true
181189
;;
@@ -663,27 +671,33 @@ function processSource {
663671
cargo run "${cargo_args[@]}" <"$HTML_SOURCE/$source_location" >"$HTML_TEMP/source-whatwg-complete"
664672
fi
665673

666-
runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
667-
if [[ $WATTSI_RESULT == "0" ]]; then
668-
if [[ $LOCAL_WATTSI != "true" ]]; then
669-
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
670-
fi
674+
if [[ $USE_BIKESHED == "true" ]]; then
675+
echo "BIKESHED!!!"
676+
bikeshed spec --byos "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/bikeshed-output" --md-Text-Macro="SHA $HTML_SHA"
677+
exit 0
671678
else
672-
if [[ $LOCAL_WATTSI != "true" ]]; then
673-
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
674-
fi
675-
if [[ $WATTSI_RESULT == "65" ]]; then
676-
echo
677-
echo "There were errors. Running again to show the original line numbers."
678-
echo
679-
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
679+
runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
680+
if [[ $WATTSI_RESULT == "0" ]]; then
680681
if [[ $LOCAL_WATTSI != "true" ]]; then
681-
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
682+
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
682683
fi
684+
else
685+
if [[ $LOCAL_WATTSI != "true" ]]; then
686+
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
687+
fi
688+
if [[ $WATTSI_RESULT == "65" ]]; then
689+
echo
690+
echo "There were errors. Running again to show the original line numbers."
691+
echo
692+
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
693+
if [[ $LOCAL_WATTSI != "true" ]]; then
694+
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
695+
fi
696+
fi
697+
echo
698+
echo "There were errors. Stopping."
699+
exit "$WATTSI_RESULT"
683700
fi
684-
echo
685-
echo "There were errors. Stopping."
686-
exit "$WATTSI_RESULT"
687701
fi
688702

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

src/main.rs

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ mod rcdom_with_line_numbers;
1818
mod represents;
1919
mod tag_omission;
2020

21+
const BIKEPLATE: &str = "<pre class=metadata>
22+
Group: WHATWG
23+
H1: HTML
24+
Shortname: html
25+
Abstract: HTML is Bikeshed.
26+
Indent: 1
27+
</pre>";
28+
2129
#[tokio::main]
2230
async fn main() -> io::Result<()> {
2331
// This gives slightly prettier error-printing.
@@ -35,6 +43,12 @@ async fn run() -> io::Result<()> {
3543
// Find the paths we need.
3644
let cache_dir = path_from_env("HTML_CACHE", ".cache");
3745
let source_dir = path_from_env("HTML_SOURCE", "../html");
46+
let use_bikeshed_str = env::var_os("USE_BIKESHED");
47+
let use_bikeshed = use_bikeshed_str.is_some_and(|s| s.eq_ignore_ascii_case("TRUE"));
48+
if use_bikeshed {
49+
eprintln!("BIKESHED MODE");
50+
println!("{}", BIKEPLATE);
51+
}
3852

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

0 commit comments

Comments
 (0)