Skip to content

Commit 3c0c97c

Browse files
committed
Add experimental support to build using Bikeshed
The new --bikeshed flag enables Bikeshed mode. The wattsi2bikeshed.js script converts the source from Wattsi to Bikeshed syntax. The hardest part of this is ensuring that cross-references still resolve to the same thing. Wattsi's <span> and <i> for autolinks are converted to <a>, but changes to HTML itself will likely be needed for some cases where the data-x="" (with hyphens) is unambiguous but where Bikeshed's linking text (with spaces) is ambiguous and would require a for="" attribute. What doesn't work: - Some cross-references as per above. - Some manual changes to HTML are still needed: https://github.com/whatwg/html/tree/bikeshed-experiment - Existing IDs aren't always preserved. - Simplification of HTML into Bikeshed shorthands like {{Node}}. - subdfn, which has no equivalent in Bikeshed. - Variants like the dev edition aren't properly supported.
1 parent 0af3f35 commit 3c0c97c

File tree

5 files changed

+1255
-24
lines changed

5 files changed

+1255
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ html/
44
output/
55
mdn/.id-list
66
mdn/developer.mozilla.org/
7+
node_modules/
78
highlighter/
89

910

build.sh

Lines changed: 48 additions & 24 deletions
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
@@ -85,14 +86,16 @@ function main {
8586
exit 0
8687
fi
8788

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

91-
doLint
93+
doLint
9294

93-
updateRemoteDataFiles
95+
updateRemoteDataFiles
9496

95-
startHighlightServer
97+
startHighlightServer
98+
fi
9699

97100
processSource "source" "default"
98101

@@ -146,6 +149,7 @@ function processCommandLineArgs {
146149
echo " $0 help Show this usage statement."
147150
echo
148151
echo "Build options:"
152+
echo " -b|--bikeshed Use Bikeshed instead of Wattsi. (experimental)"
149153
echo " -d|--docker Use Docker to build in a container."
150154
echo " -r|--remote Use the build server."
151155
echo " -s|--serve After building, serve the results on http://localhost:$SERVE_PORT."
@@ -176,6 +180,10 @@ function processCommandLineArgs {
176180
DO_HIGHLIGHT=false
177181
SINGLE_PAGE_ONLY=true
178182
;;
183+
-b|--bikeshed)
184+
USE_BIKESHED=true
185+
SINGLE_PAGE_ONLY=true
186+
;;
179187
-d|--docker)
180188
USE_DOCKER=true
181189
;;
@@ -656,34 +664,48 @@ function processSource {
656664
cp -p entities/out/entities-dtd.url "$HTML_CACHE"
657665
runRustTools <"$HTML_SOURCE/$source_location" >"$HTML_TEMP/source-whatwg-complete"
658666

659-
runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
660-
if [[ $WATTSI_RESULT == "0" ]]; then
661-
if [[ $LOCAL_WATTSI != "true" ]]; then
662-
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
663-
fi
667+
if [[ $USE_BIKESHED == "true" ]]; then
668+
clearDir "$HTML_TEMP/bikeshed-output"
669+
670+
node wattsi2bikeshed.js "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/source-whatwg-complete.bs"
671+
672+
local bikeshed_args=( --force )
673+
$DO_UPDATE || bikeshed_args+=( --no-update )
674+
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"
664675
else
665-
if [[ $LOCAL_WATTSI != "true" ]]; then
666-
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
667-
fi
668-
if [[ $WATTSI_RESULT == "65" ]]; then
669-
echo
670-
echo "There were errors. Running again to show the original line numbers."
671-
echo
672-
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
676+
runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
677+
if [[ $WATTSI_RESULT == "0" ]]; then
678+
if [[ $LOCAL_WATTSI != "true" ]]; then
679+
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
680+
fi
681+
else
673682
if [[ $LOCAL_WATTSI != "true" ]]; then
674-
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
683+
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
684+
fi
685+
if [[ $WATTSI_RESULT == "65" ]]; then
686+
echo
687+
echo "There were errors. Running again to show the original line numbers."
688+
echo
689+
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
690+
if [[ $LOCAL_WATTSI != "true" ]]; then
691+
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
692+
fi
675693
fi
694+
echo
695+
echo "There were errors. Stopping."
696+
exit "$WATTSI_RESULT"
676697
fi
677-
echo
678-
echo "There were errors. Stopping."
679-
exit "$WATTSI_RESULT"
680698
fi
681699

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

684702
if [[ $build_type == "default" ]]; then
685703
# Singlepage HTML
686-
runRustTools --singlepage-post <"$HTML_TEMP/wattsi-output/index-html" >"$HTML_OUTPUT/index.html"
704+
if [[ $USE_BIKESHED == "true" ]]; then
705+
mv "$HTML_TEMP/bikeshed-output/index.html" "$HTML_OUTPUT/index.html"
706+
else
707+
runRustTools --singlepage-post <"$HTML_TEMP/wattsi-output/index-html" >"$HTML_OUTPUT/index.html"
708+
fi
687709

688710
if [[ $SINGLE_PAGE_ONLY == "false" ]]; then
689711
# Singlepage Commit Snapshot
@@ -699,7 +721,9 @@ function processSource {
699721
fi
700722

701723
cp -p entities/out/entities.json "$HTML_OUTPUT"
702-
cp -p "$HTML_TEMP/wattsi-output/xrefs.json" "$HTML_OUTPUT"
724+
if [[ $USE_BIKESHED == "false" ]]; then
725+
cp -p "$HTML_TEMP/wattsi-output/xrefs.json" "$HTML_OUTPUT"
726+
fi
703727

704728
clearDir "$HTML_TEMP"
705729

0 commit comments

Comments
 (0)