You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
959 B
36 lines
959 B
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
usage(){
|
|
echo "usage: check_spelling.sh <source directory>"
|
|
exit 1
|
|
}
|
|
|
|
start_dir=$(pwd)
|
|
script_dir=$(dirname "$0")
|
|
cd "$script_dir"
|
|
|
|
target_dir="$1"
|
|
source_dir="$2"
|
|
|
|
cp .pyspelling.yml "$target_dir"
|
|
|
|
cd "$target_dir"
|
|
|
|
# Determine what to ignore
|
|
find "$source_dir" -type f -name "*.rpy" | xargs grep -Eno "#ignorespelling" | sed -r -e "s=${source_dir}==" | awk 'BEGIN {FS=":"}; {printf "^%s:%s\n", $1, $2}' > ignore_directives
|
|
|
|
# Find suspect words
|
|
pyspelling -n renpy_dialogue -S dialogue.txt | tail -n+4 | head -n -3 > suspect_words
|
|
|
|
# Print the suspect words
|
|
awk 'BEGIN {FS="\t"}; {printf "%s:%s\t%s\n", $4, $5, $3}' < dialogue.tab | column -ts $'\t' > pretty_dialogue.tab
|
|
echo "Ignored lines:"
|
|
grep -f ignore_directives pretty_dialogue.tab | grep --color -w -f suspect_words
|
|
printf "\nSuspected misspellings:\n"
|
|
grep -v -f ignore_directives pretty_dialogue.tab | grep --color -w -f suspect_words
|
|
|
|
cd "$start_dir"
|
|
|
|
exit 0
|