ClickHouse/utils/check-style/check-doc-aspell

53 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2022-06-02 12:18:56 +00:00
#!/usr/bin/env bash
2023-06-02 11:30:05 +00:00
# force-enable double star globbing
shopt -s globstar
2022-06-02 12:18:56 +00:00
# Perform spell checking on the docs
2022-06-03 14:10:15 +00:00
if [[ ${1:-} == "--help" ]] || [[ ${1:-} == "-h" ]]; then
echo "Usage $0 [--help|-h] [-i]"
echo " --help|-h: print this help"
echo " -i: interactive mode"
exit 0
fi
2022-06-02 12:18:56 +00:00
ROOT_PATH=$(git rev-parse --show-toplevel)
2022-06-03 14:10:15 +00:00
CHECK_LANG=en
2022-06-02 12:18:56 +00:00
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 14:10:15 +00:00
if [[ ${1:-} == "-i" ]]; then
echo "Checking $fname"
aspell --personal=aspell-dict.txt --add-sgml-skip=code --encoding=utf-8 --mode=markdown -W 3 --lang=${CHECK_LANG} --home-dir=${ASPELL_IGNORE_PATH} -c "$fname"
continue
fi
errors=$(cat "$fname" \
| aspell list \
-W 3 \
--personal=aspell-dict.txt \
--add-sgml-skip=code \
--encoding=utf-8 \
--mode=markdown \
--lang=${CHECK_LANG} \
--home-dir=${ASPELL_IGNORE_PATH} \
2022-06-02 12:18:56 +00:00
| sort | uniq)
if [ ! -z "$errors" ]; then
STATUS=1
echo "====== $fname ======"
echo "$errors"
fi
done
2022-06-03 14:10:15 +00:00
if (( STATUS != 0 )); then
echo "====== Errors found ======"
echo "To exclude some words add them to the dictionary file \"${ASPELL_IGNORE_PATH}/aspell-dict.txt\""
echo "You can also run ${0} -i to see the errors interactively and fix them or add to the dictionary file"
fi
2022-06-02 12:18:56 +00:00
exit ${STATUS}