From 3be08c9b85ec3e5432392cc058147c0f73e4288d Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 23 Mar 2020 05:57:46 -0300 Subject: [PATCH] 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. --- .github/workflows/pythonpackage.yml | 18 +- .gitignore | 1 + Makefile | 25 ++ dict | 377 ++++++++++++++++++++++++++++ requirements.txt | 1 + 5 files changed, 420 insertions(+), 2 deletions(-) create mode 100644 dict diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index ac0bf178d..5b5e382a7 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,4 +1,4 @@ -name: Build and update Documentation +name: Build and update documentation # Daily at 0 am on: @@ -31,7 +31,9 @@ jobs: - name: Install dependencies via package manager run: | sudo apt update - sudo apt install -y gettext + sudo apt install -y gettext hunspell hunspell-pt-br + msgfmt -V + hunspell -v - name: Prepare virtual environment run: | @@ -79,6 +81,18 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check spelling of translations + run: | + make spell + cd .pospell/ + tar -czf ../pospell-out.tar.gz *.txt **/*.txt + + - name: Make spellchecking output available + uses: actions/upload-artifact@v1 + with: + name: spellchecking-output + path: pospell-out.tar.gz + - name: Build documentation treating warnings as errors run: | make build CPYTHON_PATH=/tmp/cpython/ diff --git a/.gitignore b/.gitignore index 57427e91d..8489204af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.mo .tx/**/*.po venv/ +.pospell/ diff --git a/Makefile b/Makefile index 600de19b8..1ba0fa374 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ LOCALE_DIR := $(WORKDIRS)/locale JOBS := auto SPHINXERRORHANDLING := "-W" TRANSIFEX_PROJECT := python-newest +POSPELL_TMP_DIR := .pospell .PHONY: help @@ -34,6 +35,7 @@ help: @echo " tx-config Recreate an up-to-date project .tx/config; calls 'pot'" @echo " pot Create/Update POT files from source files" @echo " serve Serve a built documentation on http://localhost:8000" + @echo " spell Check spelling, storing output in $(POSPELL_TMP_DIR)" @echo "" @@ -177,9 +179,32 @@ serve: $(MAKE) -C $(CPYTHON_WORKDIR)/Doc serve +# list files for spellchecking +SRCS := $(wildcard *.po **/*.po) +DESTS = $(addprefix $(POSPELL_TMP_DIR)/out/,$(patsubst %.po,%.txt,$(SRCS))) + + +# spell: run spell checking tool in all po files listed in SRCS variable, +# storing the output in text files DESTS for proofreading. The +# DESTS target run the spellchecking, while the typos.txt target +# gather all reported issues in one file, sorted without redundancy +.PHONY: spell +spell: venv $(DESTS) $(POSPELL_TMP_DIR)/typos.txt + +$(POSPELL_TMP_DIR)/out/%.txt: %.po dict + @echo "Checking $< ..." + @mkdir -p $(@D) + @$(VENV)/bin/pospell -l $(LANGUAGE) -p dict $< > $@ || true + +$(POSPELL_TMP_DIR)/typos.txt: + @echo "Gathering all typos in $(POSPELL_TMP_DIR)/typos.txt ..." + @cut -d: -f3- $(DESTS) | sort -u > $@ + + # clean: remove all .mo files and the venv directory that may exist and # could have been created by the actions in other targets of this script .PHONY: clean clean: rm -fr $(VENV) + rm -rf $(POSPELL_TMP_DIR) find -name '*.mo' -delete diff --git a/dict b/dict new file mode 100644 index 000000000..85a3e0e75 --- /dev/null +++ b/dict @@ -0,0 +1,377 @@ +Aahz +Abelson +ActivePython +Andrew +Android +ArgumentParser +array +arrays +ascii +Ascii +async +asyncio +autoinicialização +aux +await +backend +backends +backport +Beck +BeOpen +bignum +bitbucket +Black +Blake Winton +Boddie +Boer +booleana +booleanas +Booleanas +booleano +booleanos +Borland +Bourne +buffer +buffers +bug +bugs +bytearray +bytearrays +bytecode +bytecodes +bzip +Centrum +cfuhash +chamável +Chapman +char +Christian +Circus +class +codec +Codecs +Coghlan +Collin +Compaq +const +contrabarra +Cookbook +cookies +Corporation +corrotina +corrotinas +ctypes +curl +currying +Cynthia +Cython +Dalke +Dan +datetime +DateTime +deadlock +def +Delphi +dict +dicts +distutils +Distutils +dll +doc +docstring +docstrings +doctest +Docutils +Drake +egid +elif +else +Emacs +Eric +errno +euid +except +exe +exec +execv +exp +false +Flying +foo +fork +Foundation +framework +frameworks +François +Fred +Fredrik +freeware +genexp +genexps +Gerald +gettext +GiB +github +GitHub +glob +Gnumeric +Gordin +Gordon +gzip +Hammond +Harold +hash +Haskell +Heimes +Heller +Henstridge +Hettinger +Hewlett +host +Hylton +HyperText +Ian +ids +if +import +index +Index +initgroups +Initiatives +int +Irix +IronPython +Jay +Jelke +Jeremy +Jewett +Jr +Julie +Jython +Kent +kernel +Kernel +kernels +KiB +Krell +Kuchling +Language +len +libtclsam +libtksam +Lisp +listcomp +listcomps +localtime +log +logger +Logger +loggers +Loggers +logging +Logging +logs +loop +Ltd +Ltda +Lucasfilm +Lundh +lzma +Mac +MacAfee +Macintosh +mail +mailheader +Majkowski +Mark +Markup +marshal +Mathematisch +McAfee +McMillan +memoizar +memoryview +MemoryView +Mertz +metacaractere +Metacaractere +metacaracteres +Metacaracteres +metaclasse +metaclasses +Microsoft +Minus +Mitch + mixin +mmap +Monty +Moshe +multithread +NaN +NaNs +National +ncurses +netrc +Neumann +Nick +numpy +NumPy +NxN +Object +OpenSolaris +OpenSuse +OverflowError +Packaging +Packard +patches +Patterns +pdb +PEP +Perl +Pillow +Pinard +pip +plugin +plugins +popen +PowerShell +printf +prompt +proxy +pty +PureProxy +py +Py +pyc +PyChecker +Pydb +Pylint +PyObject +PyPy +PyQt +PySide +python +Python +Pythônico +PythonLabs +Pythonwin +PythonWin +PyUnit +pyvenv +PyZipFile +qNaN +Qt +Queens +Randal +Raymond +read +referenciável +regex +Research +reStructuredText +rfc +rgid +root +Rossum +Roundup +Ruby +ruid +runner +Salmela +scanf +Scintilla +script +scripts +self +serialização +setgroups +setup +setuptools +sgid +shareware +shebang +Shebang +shell +shells +Singleton +Slice +slot +slots +smalltalk +sNaN +Snow +so +Solaris +SourceForge +spec +Sphinx +sscanf +Standard +stderr +stdin +stdout +Stichting +str +streams +Streams +stride +string +subcontexto +subcontextos +subpacote +subpacotes +subst +substring +subteste +suid +Sussman +switch +sys +tar +Tcl +Telnet +termcap +thread +threading +threads +Tix +Tk +Tkinter +token +tokens +traceback +true +try +tty +Tuininga +typedef +unicode +Unicode +unittest +upload +urllib +Usenet +User +ValueError +voltage +VxWorks +Water +wchar +while +widgets +Win +Windows +Winter +Winton +www +wxPython +wxwidgets +wxWidgets +WxWidgets +Xt +Yellow +Zadka +zipfile +ZipFile +zlib +Zope diff --git a/requirements.txt b/requirements.txt index f04463587..fb6da3812 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ transifex-client sphinx-intl powrap +pospell