Improve spell checking command so we get colorized output. (#2752)

This commit is contained in:
Martin Taillefer 2018-10-08 22:31:10 -07:00 committed by GitHub
parent 465c5fe5e6
commit 28900ad96c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 12 deletions

View File

@ -1,8 +1,8 @@
version: 2 version: 2.1
jobs: jobs:
build: build:
docker: docker:
- image: gcr.io/istio-testing/website-builder:2018-10-05 - image: gcr.io/istio-testing/website-builder:2018-10-08
working_directory: ~/site working_directory: ~/site

View File

@ -1,5 +1,5 @@
img := gcr.io/istio-testing/website-builder:2018-10-05 img := gcr.io/istio-testing/website-builder:2018-10-08
docker := docker run -t -i --sig-proxy=true --rm -v $(shell pwd):/site -w /site $(img) docker := docker run -t -i --sig-proxy=true --rm -v $(shell pwd):/site -w /site $(img)
ifeq ($(CONTEXT),production) ifeq ($(CONTEXT),production)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/bin/bash
FAILED=0 FAILED=0
@ -16,13 +16,14 @@ check_content() {
DIR=$1 DIR=$1
LANG=$2 LANG=$2
TMP=$(mktemp -d) TMP=$(mktemp -d)
OUT=$(mktemp)
# make the tmp dir # make the tmp dir
mkdir -p ${TMP} mkdir -p ${TMP}
# create a throwaway copy of the content # create a throwaway copy of the content
cp -R ${DIR} ${TMP} cp -R ${DIR} ${TMP}
cp .spelling ${TMP}
cp mdl_style.rb ${TMP}
# replace the {{< text >}} shortcodes with ```plain # replace the {{< text >}} shortcodes with ```plain
find ${TMP} -type f -name \*.md -exec sed -E -i "s/\\{\\{< text .*>\}\}/\`\`\`plain/g" {} ";" find ${TMP} -type f -name \*.md -exec sed -E -i "s/\\{\\{< text .*>\}\}/\`\`\`plain/g" {} ";"
@ -36,26 +37,27 @@ check_content() {
# elide link="*" # elide link="*"
find ${TMP} -type f -name \*.md -exec sed -E -i "s/link=\".*\"/LINK/g" {} ";" find ${TMP} -type f -name \*.md -exec sed -E -i "s/link=\".*\"/LINK/g" {} ";"
mdspell ${LANG} --ignore-acronyms --ignore-numbers --no-suggestions --report ${TMP}/*.md ${TMP}/*/*.md ${TMP}/*/*/*.md ${TMP}/*/*/*/*.md ${TMP}/*/*/*/*/*.md ${TMP}/*/*/*/*/*/*.md ${TMP}/*/*/*/*/*/*/*.md >${OUT} # switch to the temp dir
pushd ${TMP} >/dev/null
mdspell ${LANG} --ignore-acronyms --ignore-numbers --no-suggestions --report *.md */*.md */*/*.md */*/*/*.md */*/*/*/*.md */*/*/*/*/*.md */*/*/*/*/*/*.md
if [ "$?" != "0" ] if [ "$?" != "0" ]
then then
# remove the tmp dir prefix from error messages
sed s!${TMP}/!! ${OUT}
echo "To learn how to address spelling errors, please see https://github.com/istio/istio.io#linting" echo "To learn how to address spelling errors, please see https://github.com/istio/istio.io#linting"
FAILED=1 FAILED=1
fi fi
mdl --ignore-front-matter --style mdl_style.rb ${TMP} >${OUT} mdl --ignore-front-matter --style mdl_style.rb .
if [ "$?" != "0" ] if [ "$?" != "0" ]
then then
# remove the tmp dir prefix from error messages
sed s!${TMP}/!! ${OUT}
FAILED=1 FAILED=1
fi fi
# go back whence we came
popd >/dev/null
# cleanup # cleanup
rm -fr ${TMP} rm -fr ${TMP}
rm -fr ${OUT}
} }
check_content content --en-us check_content content --en-us