8000 Simplify `make` a lot · python/python-docs-es@62a179f · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 62a179f

Browse files
committed
Simplify make a lot
1 parent feb6c86 commit 62a179f

File tree

6 files changed

+32
-133
lines changed

6 files changed

+32
-133
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cpython/locale
12
*.mo
23
/_build/
34

.overrides/CONTRIBUTING.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
Guía para contribuir en la traducción
24
=====================================
35

.overrides/translation-memory.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
=======================
24
Memoria de traducción
35
=======================

.overrides/upgrade-python-version.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
=======================================
24
How to update to a new Python version
35
=======================================

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ before_install:
55
- sudo apt-get update
66
- sudo apt-get install -y hunspell hunspell-es
77
install:
8-
- pip install pospell "powrap>=0.3.0"
8+
- make setup
99
- pospell --version
1010
- powrap --version
1111
script:
1212
- powrap --check --quiet **/*.po
13-
- pospell -p dict -l es_ES **/*.po
13+
- make spell
1414
- make build

Makefile

Lines changed: 23 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,28 @@
88
# Configuration
99

1010
CPYTHON_PATH := cpython #Current commit for this upstream repo is setted by the submodule
11-
BRANCH := 3.7
11+
BRANCH := 3.8
1212
LANGUAGE_TEAM := python-docs-es
1313
LANGUAGE := es
1414

1515
# Internal variables
1616
VENV := $(shell realpath ./venv)
1717
PYTHON := $(shell which python3)
18-
WORKDIRS := $(VENV)/workdirs
19-
CPYTHON_WORKDIR := $(WORKDIRS)/cpython
20-
LOCALE_DIR := $(WORKDIRS)/locale
21-
JOBS := auto
22-
SPHINXERRORHANDLING := "-W"
23-
TRANSIFEX_PROJECT := python-newest
18+
CPYTHON_WORKDIR := cpython
19+
OUTPUT_DOCTREE := $(CPYTHON_WORKDIR)/Doc/_build/doctree
20+
OUTPUT_HTML := $(CPYTHON_WORKDIR)/Doc/_build/html
21+
LOCALE_DIR := $(CPYTHON_WORKDIR)/locale
22+
TRANSIFEX_PROJECT := python-docs-es
2423
POSPELL_TMP_DIR := .pospell
2524

2625

2726
.PHONY: help
2827
help:
2928
@echo "Please use 'make <target>' where <target> is one of:"
3029
@echo " build Build an local version in html, with warnings as errors"
31-
@echo " push Update translations and Transifex config in the repository"
32-
@echo " pull Download translations from Transifex; calls 'venv'"
33-
@echo " tx-config Recreate an up-to-date project .tx/config; calls 'pot'"
34-
@echo " pot Create/Update POT files from source files"
3530
@echo " serve Serve a built documentation on http://localhost:8000"
36-
@echo " spell Check spelling, storing output in $(POSPELL_TMP_DIR)"
31+
@echo " spell Check spelling"
32+
@echo " wrap Wrap all the PO files to a fixed column width"
3733
@echo " progress To compute current progression on the tutorial"
3834
@echo ""
3935

@@ -44,125 +40,33 @@ help:
4440
# treated as errors, which is good to skip simple Sphinx syntax mistakes.
4541
.PHONY: build
4642
build: setup
47-
$(MAKE) -C $(CPYTHON_WORKDIR)/Doc/ \
48-
VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv \
49-
PYTHON=$(PYTHON) \
50-
SPHINXERRORHANDLING=$(SPHINXERRORHANDLING) \
51-
SPHINXOPTS='-q --keep-going -j$(JOBS) \
52-
-D locale_dirs=$(LOCALE_DIR) \
53-
-D language=$(LANGUAGE) \
54-
-D gettext_compact=0 \
55-
-D latex_engine=xelatex \
56-
-D latex_elements.inputenc= \
57-
-D latex_elements.fontenc=' \
58-
html;
59-
60-
@echo "Success! Open file://$(CPYTHON_WORKDIR)/Doc/build/html/index.html, " \
43+
sphinx-build -j auto -b html -d $(OUTPUT_DOCTREE) -D language=$(LANGUAGE) . $(OUTPUT_HTML)
44+
@echo "Success! Open file://`pwd`/$(OUTPUT_HTML)/index.html, " \
6145
"or run 'make serve' to see them in http://localhost:8000";
6246

6347

64-
# push: push new translation files and Transifex config files to repository,
65-
# if any. Do nothing if there is no file changes. If GITHUB_TOKEN is set,
66-
# then assumes we are in GitHub Actions, requiring different push args
67-
.PHONY: push
68-
push:
69-
if ! git status -s | egrep '\.po|\.tx/config'; then \
70-
echo "Nothing to commit"; \
71-
exit 0; \
72-
else \
73-
git add *.po **/*.po .tx/config; \
74-
git commit -m 'Update translations from Transifex'; \
75-
if [ $(GITHUB_TOKEN) != "" ]; then \
76-
header="$(echo -n token:"$(GITHUB_TOKEN)" | base64)"; \
77-
git -c http.extraheader="AUTHORIZATION: basic $(header)" push; \
78-
else \
79-
git push; \
80-
fi; \
81-
fi
82-
83-
84-
# pull: Download translations files from Transifex, and apply line wrapping.
85-
# For downloading new translation files, first run "tx-config" target
86-
# to update the translation file mapping.
87-
.PHONY: pull
88-
pull: venv
89-
$(VENV)/bin/tx pull --force --language=$(LANGUAGE) --parallel
90-
$(VENV)/bin/powrap --quiet *.po **/*.po
91-
92-
93-
# tx-config: After running "pot", create a new Transifex config file by
94-
# reading pot files generated, then tweak this config file to
95-
# LANGUAGE.
96-
.PHONY: tx-config
97-
tx-config: pot
98-
cd $(CPYTHON_WORKDIR)/Doc/locales; \
99-
rm -rf .tx; \
100-
$(VENV)/bin/sphinx-intl create-txconfig; \
101-
$(VENV)/bin/sphinx-intl update-txconfig-resources \
102-
--transifex-project-name=$(TRANSIFEX_PROJECT) \
103-
--locale-dir . \
104-
--pot-dir pot;
105-
106-
cd $(OLDPWD)
107-
mv $(CPYTHON_WORKDIR)/Doc/locales/.tx/config .tx/config
108-
109-
sed -i .tx/config \
110-
-e '/^source_file/d' \
111-
-e 's|<lang>/LC_MESSAGES/||' \
112-
-e "s|^file_filter|trans.$(LANGUAGE)|"
113-
114-
115-
# pot: After running "setup" target, run a cpython Makefile's target
116-
# to generate .pot files under $(CPYTHON_WORKDIR)/Doc/locales/pot
117-
.PHONY: pot
118-
pot: setup
119-
$(MAKE) -C $(CPYTHON_WORKDIR)/Doc/ \
120-
VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv \
121-
PYTHON=$(PYTHON) \
122-
ALLSPHINXOPTS='-E -b gettext \
123-
-D gettext_compact=0 \
124-
-d build/.doctrees . \
125-
locales/pot' \
126-
build
127-
128-
12948
# setup: After running "venv" target, prepare that virtual environment with
13049
# a local clone of cpython repository and the translation files.
13150
# If the directories exists, only update the cpython repository and
13251
# the translation files copy which could have new/updated files.
13352
.PHONY: setup
13453
setup: venv
135-
# Setup the main clone
13654
git submodule sync
13755
git submodule update --init --force $(CPYTHON_PATH)
138-
# Setup the current work directory
139-
if ! [ -d $(CPYTHON_WORKDIR) ]; then \
140-
rm -fr $(WORKDIRS); \
141-
mkdir -p $(WORKDIRS); \
142-
git clone $(CPYTHON_PATH) $(CPYTHON_WORKDIR); \
143-
$(MAKE) -C $(CPYTHON_WORKDIR)/Doc \
144-
VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv \
145-
PYTHON=$(PYTHON) venv; \
146-
fi
147-
148-
# Setup translation files
149-
if ! [ -d $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/ ]; then \
150-
mkdir -p $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/; \
151-
fi; \
152-
cp --parents *.po **/*.po $(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/ \
15356

15457

15558
# venv: create a virtual environment which will be used by almost every
15659
# other target of this script
15760
.PHONY: venv
15861
venv:
159-
if [ ! -d $(VENV) ]; then \
62+
if [ ! -d $(VENV) ]; then \
16063
$(PYTHON) -m venv --prompt $(LANGUAGE_TEAM) $(VENV); \
16164
fi
16265

16366
$(VENV)/bin/python -m pip install -q -r requirements.txt 2> $(VENV)/pip-install.log
16467

165-
if grep -q 'pip install --upgrade pip' $(VENV)/pip-install.log; then \
68+
if grep -q 'pip install --upgrade pip' $(VENV)/pip-install.log; \
69+
then \
16670
$(VENV)/bin/pip install -q --upgrade pip; \
16771
fi
16872

@@ -174,28 +78,6 @@ serve:
17478
$(MAKE) -C $(CPYTHON_WORKDIR)/Doc serve
17579

17680

177-
# list files for spellchecking
178-
SRCS := $(wildcard *.po **/*.po)
179-
DESTS = $(addprefix $(POSPELL_TMP_DIR)/out/,$(patsubst %.po,%.txt,$(SRCS)))
180-
181-
182-
# spell: run spell checking tool in all po files listed in SRCS variable,
183-
# storing the output in text files DESTS for proofreading. The
184-
# DESTS target run the spellchecking, while the typos.txt target
185-
# gather all reported issues in one file, sorted without redundancy
186-
.PHONY: spell
187-
spell: venv $(DESTS) $(POSPELL_TMP_DIR)/typos.txt
188-
189-
$(POSPELL_TMP_DIR)/out/%.txt: %.po dict
190-
@echo "Checking $< ..."
191-
@mkdir -p $(@D)
192-
@$(VENV)/bin/pospell -l $(LANGUAGE) -p dict $< > $@ || true
193-
194-
$(POSPELL_TMP_DIR)/typos.txt:
195-
@echo "Gathering all typos in $(POSPELL_TMP_DIR)/typos.txt ..."
196-
@cut -d: -f3- $(DESTS) | sort -u > $@
197-
198-
19981
# clean: remove all .mo files and the venv directory that may exist and
20082
# could have been created by the actions in other targets of this script
20183
.PHONY: clean
@@ -207,3 +89,13 @@ clean:
20789
.PHONY: progress
20890
progress: venv
20991
$(VENV)/bin/potodo --offline --path tutorial/
92+
93+
94+
.PHONY: spell
95+
spell: venv
96+
$(VENV)/bin/pospell -p dict -l es_ES **/*.po
97+
98+
99+
.PHONY: wrap
100+
wrap: venv
101+
$(VENV)/bin/powrap **/*.po

0 commit comments

Comments
 (0)
0