Skip to content
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

Add MDN annotations to spec output #184

Merged
merged 4 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.temp/
html/
output/
mdn/.id-list
mdn/developer.mozilla.org/
30 changes: 24 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cd "$(dirname "$0")"
DIR=$(pwd)

# The latest required version of Wattsi. Update this if you change how ./build.sh invokes Wattsi.
WATTSI_LATEST=70
WATTSI_LATEST=76

# Shared state variables throughout this script
LOCAL_WATTSI=true
Expand Down Expand Up @@ -65,7 +65,7 @@ function main {

clearCacheIfNecessary

updateCanIUseFile
updateRemoteDataFiles

rm -rf "$HTML_OUTPUT" && mkdir -p "$HTML_OUTPUT"
# Set these up so rsync will not complain about either being missing
Expand Down Expand Up @@ -414,24 +414,38 @@ function clearCacheIfNecessary {
fi
}

# Updates the caniuse.json file, if either $DO_UPDATE is true or the file is not yet cached.
# Updates the caniuse.json and mdn-spec-links-html.json files, if either
# $DO_UPDATE is true or they are not yet cached.
# Arguments: none
# Output:
# - $HTML_CACHE will contain a usable caniuse.json file
function updateCanIUseFile {
function updateRemoteDataFiles {
CURL_ARGS=()
if ! $VERBOSE; then
CURL_ARGS+=( --silent )
fi

CURL_CANIUSE_ARGS=( "${CURL_ARGS[@]}" --output "$HTML_CACHE/caniuse.json" -k )
CURL_CANIUSE_ARGS=( "${CURL_ARGS[@]}" \
--output "$HTML_CACHE/caniuse.json" -k )
CURL_MDN_SPEC_LINKS_ARGS=( "${CURL_ARGS[@]}" \
--output "$HTML_CACHE/mdn-spec-links-html.json" -k )


if [[ $DO_UPDATE == "true" || ! -f "$HTML_CACHE/caniuse.json" ]]; then
rm -f "$HTML_CACHE/caniuse.json"
$QUIET || echo "Downloading caniuse data..."
curl "${CURL_CANIUSE_ARGS[@]}" \
https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json
fi

if [[ $DO_UPDATE == "true" \
|| ! -f "$HTML_CACHE/mdn-spec-links-html.json" ]]; then
rm -f "$HTML_CACHE/mdn-spec-links-html.json"
$QUIET || echo "Downloading mdn-spec-links/html.json..."
curl "${CURL_MDN_SPEC_LINKS_ARGS[@]}" \
https://raw.githubusercontent.com/w3c/mdn-spec-links/master/html.json
fi

}

# Performs a build of the HTML source file into the resulting output
Expand Down Expand Up @@ -535,7 +549,10 @@ function runWattsi {
if $QUIET; then
WATTSI_ARGS+=( --quiet )
fi
WATTSI_ARGS+=( "$1" "$HTML_SHA" "$2" "$BUILD_TYPE" "$HTML_CACHE/caniuse.json" "$HIGHLIGHT_SERVER_URL" )
WATTSI_ARGS+=( "$1" "$HTML_SHA" "$2" "$BUILD_TYPE" \
"$HTML_CACHE/caniuse.json" \
"$HTML_CACHE/mdn-spec-links-html.json" \
"$HIGHLIGHT_SERVER_URL" )
if hash wattsi 2>/dev/null; then
if [[ "$(wattsi --version | cut -d' ' -f2)" -lt "$WATTSI_LATEST" ]]; then
echo
Expand All @@ -555,6 +572,7 @@ function runWattsi {
--form "sha=$HTML_SHA" \
--form "build=$BUILD_TYPE" \
--form "caniuse=@$HTML_CACHE/caniuse.json" \
--form "mdn=@HTML_CACHE/mdn-spec-links-html.json" \
--dump-header "$HTML_TEMP/wattsi-headers.txt" \
--output "$HTML_TEMP/wattsi-output.zip" )
if $VERBOSE; then
Expand Down