diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 5b5e382a7..ceed50299 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,60 +1,36 @@ name: Build and update documentation # Daily at 0 am -on: - schedule: - - cron: '0 0 * * *' +#on: +# schedule: +# - cron: '0 0 * * *' +on: push + +# Branch where translation takes place +env: + BRANCH: 3.8 jobs: - build: + # Job to pull, build and push translations from Transifex to the repository + update: if: (github.event_name == 'schedule' && github.repository == 'python/python-docs-pt-br') || (github.event_name != 'schedule') runs-on: ubuntu-latest strategy: max-parallel: 4 - matrix: - python-version: [3.7] steps: - uses: actions/checkout@v2 with: - ref: 3.8 - - run: | - git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies via package manager - run: | - sudo apt update - sudo apt install -y gettext hunspell hunspell-pt-br - msgfmt -V - hunspell -v - - - name: Prepare virtual environment - run: | - make venv - venv/bin/pip --version - venv/bin/tx --version - venv/bin/sphinx-intl --help - venv/bin/powrap --version - - - name: If failed, make the log file an artifact - if: failure() - uses: actions/upload-artifact@v1 - with: - name: pip-install-log - path: venv/pip-install.log + ref: ${{ env.BRANCH }} - - name: Recreate an up-to-date project .tx/config - run: | - make tx-config + - uses: actions/setup-python@v2 + - run: sudo apt update + - run: sudo apt install -y gettext + - run: make tx-config - - name: Update translations from Transifex + - name: Run make pull run: | if [[ -n "$TRANSIFEX_APIKEY" ]]; then echo -e "[https://www.transifex.com]\n" \ @@ -69,11 +45,9 @@ jobs: env: TRANSIFEX_APIKEY: ${{ secrets.TRANSIFEX_APIKEY }} - - name: Build documentation - run: | - make build CPYTHON_PATH=/tmp/cpython/ SPHINXERRORHANDLING='' + - run: make build CPYTHON_PATH=/tmp/cpython/ SPHINXERRORHANDLING='' - - name: Push translations + - name: Run make push run: | git config user.email "github-actions[bot]@users.noreply.github.com" git config user.name "github-actions[bot]" @@ -81,18 +55,79 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check spelling of translations + # Job to check spelling of translations + spellcheck: + needs: update + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH }} + + - uses: actions/setup-python@v2 + - run: sudo apt update + - run: sudo apt install -y gettext hunspell hunspell-pt-br + + - name: Run make spell run: | make spell cd .pospell/ tar -czf ../pospell-out.tar.gz *.txt **/*.txt - - name: Make spellchecking output available - uses: actions/upload-artifact@v1 + - name: Update artifact spellchecking-output + uses: actions/upload-artifact@v2 with: name: spellchecking-output path: pospell-out.tar.gz - - name: Build documentation treating warnings as errors + # Job to merge translation from current BRANCH to older ones + merge: + needs: update + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH }} + + - run: | + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + + - uses: actions/setup-python@v2 + - run: sudo apt update + - run: sudo apt install -y gettext + + - name: Run make push run: | - make build CPYTHON_PATH=/tmp/cpython/ + git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + make merge + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Job to build translated documentation treating warnings as errors + build-warn-as-err: + needs: update + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH }} + + - uses: actions/setup-python@v2 + - run: make build CPYTHON_PATH=/tmp/cpython/ 2> >(tee -a build-log.txt >&2) + + - name: Update artifact spellchecking-output + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: build-output + path: build-log.txt diff --git a/Makefile b/Makefile index 1ba0fa374..b1384d888 100644 --- a/Makefile +++ b/Makefile @@ -5,26 +5,41 @@ # based on: https://github.com/python/python-docs-fr/blob/3.8/Makefile # +################# # Configuration -CPYTHON_PATH := ../cpython -BRANCH := 3.8 +# Main translation branch; please make sure it matches 'python-newest' +# project's version in 'python-docs' organization in Transifex +BRANCH := $(shell git branch --show-current) + +# Branches representing docs for older Python versions, which current +# translations should be merged into +MERGEBRANCHES := 3.7 3.6 2.7 + +# Name of language team; should be python-docs-LANG, where LANG is the +# IETF language tag for your language; see Language Tag section in PEP 545 LANGUAGE_TEAM := python-docs-pt-br -LANGUAGE := pt_BR -# Internal variables +# Language code in ISO 639; see Language Tag section in PEP 545, and +# Sphinx configuration's supported languages +LANGUAGE := pt_BR +# Paths and URLs UPSTREAM := https://github.com/python/cpython -VENV := $(shell realpath ./venv) PYTHON := $(shell which python3) +CPYTHON_PATH := $(shell realpath ../cpython) +POSPELL_TMP_DIR := .pospell +VENV := $(shell realpath ./venv) WORKDIRS := $(VENV)/workdirs CPYTHON_WORKDIR := $(WORKDIRS)/cpython LOCALE_DIR := $(WORKDIRS)/locale + +# Settings for 'build' target JOBS := auto SPHINXERRORHANDLING := "-W" -TRANSIFEX_PROJECT := python-newest -POSPELL_TMP_DIR := .pospell +# +################# .PHONY: help help: @@ -36,6 +51,7 @@ help: @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 " merge Merge $(BRANCH) branch's .po files into: $(MERGEBRANCHES)" @echo "" @@ -45,7 +61,8 @@ help: # treated as errors, which is good to skip simple Sphinx syntax mistakes. .PHONY: build build: setup - $(MAKE) -C $(CPYTHON_WORKDIR)/Doc/ \ + @echo "Building Python $(BRANCH) Documentation ..." + @$(MAKE) -C $(CPYTHON_WORKDIR)/Doc/ \ VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv \ PYTHON=$(PYTHON) \ SPHINXERRORHANDLING=$(SPHINXERRORHANDLING) \ @@ -56,18 +73,18 @@ build: setup -D latex_engine=xelatex \ -D latex_elements.inputenc= \ -D latex_elements.fontenc=' \ - html; + html - @echo "Success! Open file://$(CPYTHON_WORKDIR)/Doc/build/html/index.html, " \ - "or run 'make serve' to see them in http://localhost:8000"; + @echo "Success! Open file://$(CPYTHON_WORKDIR)/Doc/build/html/index.html, " \ + "or run 'make serve' to see them in http://localhost:8000"; -# push: push new translation files and Transifex config files to repository, -# if any. Do nothing if there is no file changes. If GITHUB_TOKEN is set, -# then assumes we are in GitHub Actions, requiring different push args +# push: push changed translation files and Transifex config file to repository. +# Do nothing if there is no file changes. If GITHUB_TOKEN is set, then +# assumes we are in GitHub Actions, requiring different push args. .PHONY: push push: - if ! git status -s | egrep '\.po|\.tx/config'; then \ + @if ! git status -s | egrep '\.po|\.tx/config'; then \ echo "Nothing to commit"; \ exit 0; \ else \ @@ -87,16 +104,16 @@ push: # to update the translation file mapping. .PHONY: pull pull: venv - $(VENV)/bin/tx pull --force --language=$(LANGUAGE) --parallel - $(VENV)/bin/powrap --quiet *.po **/*.po + @$(VENV)/bin/tx pull --force --language=$(LANGUAGE) --parallel + @$(VENV)/bin/powrap --quiet *.po **/*.po # tx-config: After running "pot", create a new Transifex config file by -# reading pot files generated, then tweak this config file to -# LANGUAGE. +# reading pot files generated, then tweak it to LANGUAGE. .PHONY: tx-config +tx-config: TRANSIFEX_PROJECT := python-newest tx-config: pot - cd $(CPYTHON_WORKDIR)/Doc/locales; \ + @cd $(CPYTHON_WORKDIR)/Doc/locales; \ rm -rf .tx; \ $(VENV)/bin/sphinx-intl create-txconfig; \ $(VENV)/bin/sphinx-intl update-txconfig-resources \ @@ -104,20 +121,19 @@ tx-config: pot --locale-dir . \ --pot-dir pot; - cd $(OLDPWD) - mv $(CPYTHON_WORKDIR)/Doc/locales/.tx/config .tx/config - - sed -i .tx/config \ + @mkdir -p .tx + @sed $(CPYTHON_WORKDIR)/Doc/locales/.tx/config \ -e '/^source_file/d' \ -e 's|/LC_MESSAGES/||' \ - -e "s|^file_filter|trans.$(LANGUAGE)|" + -e "s|^file_filter|trans.$(LANGUAGE)|" \ + > .tx/config # pot: After running "setup" target, run a cpython Makefile's target -# to generate .pot files under $(CPYTHON_WORKDIR)/Doc/locales/pot +# to generate .pot files under $(CPYTHON_WORKDIR)/Doc/locales/pot. .PHONY: pot pot: setup - $(MAKE) -C $(CPYTHON_WORKDIR)/Doc/ \ + @$(MAKE) -C $(CPYTHON_WORKDIR)/Doc/ \ VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv \ PYTHON=$(PYTHON) \ ALLSPHINXOPTS='-E -b gettext \ @@ -133,62 +149,63 @@ pot: setup # the translation files copy which could have new/updated files. .PHONY: setup setup: venv - # Setup the main clone - if ! [ -d $(CPYTHON_PATH) ]; then \ - git clone --depth 1 --branch $(BRANCH) $(UPSTREAM) $(CPYTHON_PATH); \ + @if ! [ -d $(CPYTHON_PATH) ]; then \ + echo "CPython repo not found; cloning ..."; \ + git clone --depth 1 --no-single-branch $(UPSTREAM) $(CPYTHON_PATH); \ + git -C $(CPYTHON_PATH) checkout $(BRANCH); \ else \ + echo "CPython repo found; updating ..."; \ + git -C $(CPYTHON_PATH) checkout $(BRANCH); \ git -C $(CPYTHON_PATH) pull --rebase; \ fi - # Setup the current work directory - if ! [ -d $(CPYTHON_WORKDIR) ]; then \ + @if ! [ -d $(CPYTHON_WORKDIR) ]; then \ + echo "Setting up CPython repo in workdir ..."; \ rm -fr $(WORKDIRS); \ mkdir -p $(WORKDIRS); \ git clone $(CPYTHON_PATH) $(CPYTHON_WORKDIR); \ $(MAKE) -C $(CPYTHON_WORKDIR)/Doc \ VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv \ PYTHON=$(PYTHON) venv; \ + else \ + echo "CPython repo already ready in workdir"; \ fi - # Setup translation files - if ! [ -d $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/ ]; then \ + @echo "Setting up translation files in workdir ..." + @if ! [ -d $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/ ]; then \ mkdir -p $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/; \ - fi; \ - cp --parents *.po **/*.po $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/ \ + fi + @cp --parents *.po **/*.po $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/ # venv: create a virtual environment which will be used by almost every -# other target of this script +# other target of this script. .PHONY: venv venv: - if [ ! -d $(VENV) ]; then \ - $(PYTHON) -m venv --prompt $(LANGUAGE_TEAM) $(VENV); \ - fi - - $(VENV)/bin/python -m pip install -q -r requirements.txt 2> $(VENV)/pip-install.log - - if grep -q 'pip install --upgrade pip' $(VENV)/pip-install.log; then \ - $(VENV)/bin/pip install -q --upgrade pip; \ + @if [ ! -d $(VENV) ]; then \ + echo "Setting up $(LANGUAGE_TEAM)'s virtual environment ..."; \ + $(PYTHON) -m venv --prompt $(LANGUAGE_TEAM) $(VENV); \ + $(VENV)/bin/python -m pip install --upgrade pip; \ fi + @$(VENV)/bin/pip install --upgrade --requirement requirements.txt # serve: serve the documentation in a simple local web server, using cpython # Makefile's "serve" target. Run "build" before using this target. .PHONY: serve 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))) + @$(MAKE) -C $(CPYTHON_WORKDIR)/Doc serve # 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 +# gather all reported issues in one file, sorted without redundancy. .PHONY: spell + +SRCS := $(wildcard *.po **/*.po) +DESTS = $(addprefix $(POSPELL_TMP_DIR)/out/,$(patsubst %.po,%.txt,$(SRCS))) + spell: venv $(DESTS) $(POSPELL_TMP_DIR)/typos.txt $(POSPELL_TMP_DIR)/out/%.txt: %.po dict @@ -201,8 +218,30 @@ $(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 +# merge: merge translations from BRANCH (Python version currently aim of +# translation) into each branch listed by MERGEBRANCHES (branches +# of older Python versions) so that older versions of the Python +# docs make at least some use the latest translations, if possible. +# After merging, git-push merged files (if any) to the target branch. +.PHONY: merge +merge: venv $(MERGEBRANCHES) + +$(MERGEBRANCHES): + @echo "Merging translations from $(BRANCH) branch into $@ ..." + @$(VENV)/bin/pomerge --from-files *.po **/*.po + @git checkout $@ + @$(VENV)/bin/pomerge --no-overwrite --to-files *.po **/*.po + @$(VENV)/bin/powrap --modified *.po **/*.po + @if git status -s | egrep '\.po'; then \ + git add *.po **/*.po; \ + git commit -m "pomerge from $(BRANCH) branch into @"; \ + git push; \ + fi + @git checkout $(BRANCH) + + +# 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) diff --git a/library/importlib.po b/library/importlib.po index 67cf54dd5..77a27d872 100644 --- a/library/importlib.po +++ b/library/importlib.po @@ -1546,7 +1546,7 @@ msgstr "" #: ../../library/importlib.rst:1311 msgid "(``__loader__``)" -msgstr "" +msgstr "(``__loader__``)" #: ../../library/importlib.rst:1313 msgid "" diff --git a/library/stdtypes.po b/library/stdtypes.po index e73c6baac..825962c25 100644 --- a/library/stdtypes.po +++ b/library/stdtypes.po @@ -10,9 +10,9 @@ # (Douglas da Silva) , 2017 # Raphael Mendonça, 2017 # Claudio Rogerio Carvalho Filho , 2017 -# Rafael Fontenelle , 2020 # Adorilson Bezerra , 2020 # Vinicius Gubiani Ferreira , 2020 +# Rafael Fontenelle , 2020 # #, fuzzy msgid "" @@ -21,7 +21,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-03-04 12:51+0000\n" "PO-Revision-Date: 2017-02-16 23:27+0000\n" -"Last-Translator: Vinicius Gubiani Ferreira , 2020\n" +"Last-Translator: Rafael Fontenelle , 2020\n" "Language-Team: Portuguese (Brazil) (https://www.transifex.com/python-doc/" "teams/5390/pt_BR/)\n" "MIME-Version: 1.0\n" @@ -5701,7 +5701,7 @@ msgid "" "Instances of :class:`set` and :class:`frozenset` provide the following " "operations:" msgstr "" -"Instâncias de:class:`set` e :class:`frozenset` fornecem as seguintes " +"Instâncias de :class:`set` e :class:`frozenset` fornecem as seguintes " "operações:" #: ../../library/stdtypes.rst:4004 diff --git a/requirements.txt b/requirements.txt index fb6da3812..50e73f386 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ transifex-client sphinx-intl powrap pospell +pomerge