mirror of
https://github.com/codespell-project/codespell.git
synced 2025-08-06 18:24:41 +08:00
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
This commit is contained in:
42
Makefile
42
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
|
||||
|
Reference in New Issue
Block a user