Sort multiple dictionaries (#1475) * Check all the dictionaries are sorted * Sort and trim all dictionaries * Add a github action to run make check-dictionary * Fix the grammar of the tasks, but keep the old ones for backwards compatibility * Use the new Makefile methods everywhere and update docs * Sort the dictionaries
diff --git a/.github/workflows/codespell-private.yml b/.github/workflows/codespell-private.yml new file mode 100644 index 0000000..e7c5f00 --- /dev/null +++ b/.github/workflows/codespell-private.yml
@@ -0,0 +1,11 @@ +# GitHub Action to check our dictionary, this should only be used by the codespell project itself +# For general usage in your repo, see the example in codespell.yml +# https://github.com/codespell-project/codespell +name: codespell +on: [push, pull_request] +jobs: + make-check-dictionaries: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: make check-dictionaries
diff --git a/Makefile b/Makefile index 2f828b7..9b26724 100644 --- a/Makefile +++ b/Makefile
@@ -1,33 +1,43 @@ SORT_ARGS := -f -b -DICTIONARY := codespell_lib/data/dictionary.txt +DICTIONARIES := codespell_lib/data/dictionary*.txt -PHONY := all check check-dictionary sort-dictionary trim-dictionary clean +PHONY := all check check-dictionaries sort-dictionaries trim-dictionaries check-dictionary sort-dictionary trim-dictionary clean -all: check-dictionary codespell.1 +all: check-dictionaries codespell.1 + +check-dictionary: check-dictionaries +sort-dictionary: sort-dictionaries +trim-dictionary: trim-dictionaries codespell.1: codespell.1.include bin/codespell PYTHONPATH=. help2man ./bin/codespell --include codespell.1.include --no-info --output codespell.1 sed -i '/\.SS \"Usage/,+2d' codespell.1 -check-dictionary: - @if ! LC_ALL=C sort ${SORT_ARGS} -c ${DICTIONARY}; then \ - echo "Dictionary not sorted. Sort with 'make sort-dictionary'"; \ - exit 1; \ - fi - @if egrep -n "^\s*$$|\s$$|^\s" ${DICTIONARY}; then \ - echo "Dictionary contains leading/trailing whitespace and/or blank lines. Trim with 'make trim-dictionary'"; \ - exit 1; \ - fi +check-dictionaries: + @for dictionary in ${DICTIONARIES}; do \ + if ! LC_ALL=C sort ${SORT_ARGS} -c $$dictionary; then \ + echo "Dictionary $$dictionary not sorted. Sort with 'make sort-dictionaries'"; \ + exit 1; \ + fi; \ + if egrep -n "^\s*$$|\s$$|^\s" $$dictionary; then \ + echo "Dictionary $$dictionary contains leading/trailing whitespace and/or blank lines. Trim with 'make trim-dictionaries'"; \ + exit 1; \ + fi; \ + done @if command -v pytest > /dev/null; then \ pytest codespell_lib/tests/test_dictionary.py; \ fi -sort-dictionary: - LC_ALL=C sort ${SORT_ARGS} -u -o ${DICTIONARY} ${DICTIONARY} +sort-dictionaries: + @for dictionary in ${DICTIONARIES}; do \ + LC_ALL=C sort ${SORT_ARGS} -u -o $$dictionary $$dictionary; \ + done -trim-dictionary: - sed -E -i.bak -e 's/^[[:space:]]+//; s/[[:space:]]+$$//; /^$$/d' ${DICTIONARY} && rm ${DICTIONARY}.bak +trim-dictionaries: + @for dictionary in ${DICTIONARIES}; do \ + sed -E -i.bak -e 's/^[[:space:]]+//; s/[[:space:]]+$$//; /^$$/d' $$dictionary && rm $$dictionary.bak; \ + done pypi: python setup.py sdist register upload
diff --git a/README.rst b/README.rst index 4c36ce3..8fb705f 100644 --- a/README.rst +++ b/README.rst
@@ -116,11 +116,11 @@ 2. Sort the dictionary. This is done by invoking (in the top level directory of ``codespell/``):: - make check-dictionary + make check-dictionaries If the make script finds that you need to sort the dictionary, please then run:: - make sort-dictionary + make sort-dictionaries 3. Only after this process is complete do we recommend you submit the PR.
diff --git a/codespell_lib/data/dictionary_informal.txt b/codespell_lib/data/dictionary_informal.txt index 8a4aab6..c5561bd 100644 --- a/codespell_lib/data/dictionary_informal.txt +++ b/codespell_lib/data/dictionary_informal.txt
@@ -1,4 +1,4 @@ gonna->going to -wanna->want to tho->though, to, thou, thru->through +wanna->want to
diff --git a/codespell_lib/data/dictionary_names.txt b/codespell_lib/data/dictionary_names.txt index 61f7b93..ad3441e 100644 --- a/codespell_lib/data/dictionary_names.txt +++ b/codespell_lib/data/dictionary_names.txt
@@ -1,3 +1,3 @@ -tim->time liszt->list +tim->time wight->weight, white, right, write,
diff --git a/codespell_lib/data/dictionary_rare.txt b/codespell_lib/data/dictionary_rare.txt index c647031..90115d4 100644 --- a/codespell_lib/data/dictionary_rare.txt +++ b/codespell_lib/data/dictionary_rare.txt
@@ -31,9 +31,9 @@ cristal->crystal crufts->cruft dealign->dealing +deffer->differ, defer, degrate->degrade degrates->degrades -deffer->differ, defer, dependant->dependent derails->details discontentment->discontent