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

60 lines
1.7 KiB
Plaintext
Raw 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 [filename]]"
2022-06-03 14:10:15 +00:00
echo " --help|-h: print this help"
echo " -i: interactive mode. If filename is specified, check only this file, otherwise check all files"
2022-06-03 14:10:15 +00:00
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}"
if [[ ${1:-} == "-i" ]]; then
if [[ ! -z ${2:-} ]]; then
FILES_TO_CHECK=${ROOT_PATH}/docs/${CHECK_LANG}/${2}
else
FILES_TO_CHECK=${ROOT_PATH}/docs/${CHECK_LANG}/**/*.md
fi
for fname in ${FILES_TO_CHECK}; do
2022-06-03 14:10:15 +00:00
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"
done
exit
fi
2022-06-03 14:10:15 +00:00
STATUS=0
for fname in ${ROOT_PATH}/docs/${CHECK_LANG}/**/*.md; do
2022-06-03 14:10:15 +00:00
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}