Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3be08c9

Browse files
committed
Enable spellchecking
Create 'spell' target that uses pospell tool to run spell checking on the translation files. The GitHub workflow will create an artifact containing log files, making it possible to donwload and study possible typos. The 'dict' file is a custom dictionary with words known to be found in the translation files, but that should not be considered as typo.
1 parent 53543d1 commit 3be08c9

5 files changed

Lines changed: 420 additions & 2 deletions

File tree

.github/workflows/pythonpackage.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and update Documentation
1+
name: Build and update documentation
22

33
# Daily at 0 am
44
on:
@@ -31,7 +31,9 @@ jobs:
3131
- name: Install dependencies via package manager
3232
run: |
3333
sudo apt update
34-
sudo apt install -y gettext
34+
sudo apt install -y gettext hunspell hunspell-pt-br
35+
msgfmt -V
36+
hunspell -v
3537
3638
- name: Prepare virtual environment
3739
run: |
@@ -79,6 +81,18 @@ jobs:
7981
env:
8082
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8183

84+
- name: Check spelling of translations
85+
run: |
86+
make spell
87+
cd .pospell/
88+
tar -czf ../pospell-out.tar.gz *.txt **/*.txt
89+
90+
- name: Make spellchecking output available
91+
uses: actions/upload-artifact@v1
92+
with:
93+
name: spellchecking-output
94+
path: pospell-out.tar.gz
95+
8296
- name: Build documentation treating warnings as errors
8397
run: |
8498
make build CPYTHON_PATH=/tmp/cpython/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.mo
22
.tx/**/*.po
33
venv/
4+
.pospell/

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ LOCALE_DIR := $(WORKDIRS)/locale
2323
JOBS := auto
2424
SPHINXERRORHANDLING := "-W"
2525
TRANSIFEX_PROJECT := python-newest
26+
POSPELL_TMP_DIR := .pospell
2627

2728

2829
.PHONY: help
@@ -34,6 +35,7 @@ help:
3435
@echo " tx-config Recreate an up-to-date project .tx/config; calls 'pot'"
3536
@echo " pot Create/Update POT files from source files"
3637
@echo " serve Serve a built documentation on http://localhost:8000"
38+
@echo " spell Check spelling, storing output in $(POSPELL_TMP_DIR)"
3739
@echo ""
3840

3941

@@ -177,9 +179,32 @@ serve:
177179
$(MAKE) -C $(CPYTHON_WORKDIR)/Doc serve
178180

179181

182+
# list files for spellchecking
183+
SRCS := $(wildcard *.po **/*.po)
184+
DESTS = $(addprefix $(POSPELL_TMP_DIR)/out/,$(patsubst %.po,%.txt,$(SRCS)))
185+
186+
187+
# spell: run spell checking tool in all po files listed in SRCS variable,
188+
# storing the output in text files DESTS for proofreading. The
189+
# DESTS target run the spellchecking, while the typos.txt target
190+
# gather all reported issues in one file, sorted without redundancy
191+
.PHONY: spell
192+
spell: venv $(DESTS) $(POSPELL_TMP_DIR)/typos.txt
193+
194+
$(POSPELL_TMP_DIR)/out/%.txt: %.po dict
195+
@echo "Checking $< ..."
196+
@mkdir -p $(@D)
197+
@$(VENV)/bin/pospell -l $(LANGUAGE) -p dict $< > $@ || true
198+
199+
$(POSPELL_TMP_DIR)/typos.txt:
200+
@echo "Gathering all typos in $(POSPELL_TMP_DIR)/typos.txt ..."
201+
@cut -d: -f3- $(DESTS) | sort -u > $@
202+
203+
180204
# clean: remove all .mo files and the venv directory that may exist and
181205
# could have been created by the actions in other targets of this script
182206
.PHONY: clean
183207
clean:
184208
rm -fr $(VENV)
209+
rm -rf $(POSPELL_TMP_DIR)
185210
find -name '*.mo' -delete

0 commit comments

Comments
 (0)