2022-06-02 12:18:56 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Perform spell checking on the docs
|
|
|
|
# Files casesensitive.txt and caseinsensitive.txt contains words to ignore (case insensitive and sensitive respectively)
|
|
|
|
# File todo.txt needs to be revised which words is actual misspellings
|
|
|
|
|
|
|
|
ROOT_PATH=$(git rev-parse --show-toplevel)
|
|
|
|
|
|
|
|
CHECK_LANG=${1:-en}
|
|
|
|
|
|
|
|
ASPELL_IGNORE_PATH="${ROOT_PATH}/utils/check-style/aspell-ignore/${CHECK_LANG}"
|
|
|
|
|
|
|
|
STATUS=0
|
2022-06-03 11:50:17 +00:00
|
|
|
for fname in ${ROOT_PATH}/docs/${CHECK_LANG}/**/*.md; do
|
2022-06-03 11:08:50 +00:00
|
|
|
# vvv ---- remove anchors ---- vvv
|
2022-06-03 11:50:17 +00:00
|
|
|
errors=$(cat "$fname" | sed -E 's/(^#.*) \{#[a-z-]+\}$/\1/' \
|
|
|
|
| aspell list --add-sgml-skip=code --encoding=utf-8 --mode=markdown -W 3 --lang=${CHECK_LANG} --home-dir=${ASPELL_IGNORE_PATH} \
|
2022-06-02 13:00:27 +00:00
|
|
|
| grep -Ewv -f "${ASPELL_IGNORE_PATH}/todo.txt" \
|
|
|
|
| grep -Ewvi -f "${ASPELL_IGNORE_PATH}/caseinsensitive.txt" \
|
|
|
|
| grep -Ewv -f "${ASPELL_IGNORE_PATH}/casesensitive.txt" \
|
|
|
|
| grep -Ewv "[A-Z]+" \
|
2022-06-02 12:18:56 +00:00
|
|
|
| sort | uniq)
|
|
|
|
if [ ! -z "$errors" ]; then
|
|
|
|
STATUS=1
|
|
|
|
echo "====== $fname ======"
|
|
|
|
echo "$errors"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit ${STATUS}
|