8
8
# Configuration
9
9
10
10
CPYTHON_PATH := cpython # Current commit for this upstream repo is setted by the submodule
11
- BRANCH := 3.7
11
+ BRANCH := 3.8
12
12
LANGUAGE_TEAM := python-docs-es
13
13
LANGUAGE := es
14
14
15
15
# Internal variables
16
16
VENV := $(shell realpath ./venv)
17
17
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
24
23
POSPELL_TMP_DIR := .pospell
25
24
26
25
27
26
.PHONY : help
28
27
help :
29
28
@echo " Please use 'make <target>' where <target> is one of:"
30
29
@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"
35
30
@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"
37
33
@echo " progress To compute current progression on the tutorial"
38
34
@echo " "
39
35
@@ -44,125 +40,33 @@ help:
44
40
# treated as errors, which is good to skip simple Sphinx syntax mistakes.
45
41
.PHONY : build
46
42
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, " \
61
45
" or run 'make serve' to see them in http://localhost:8000" ;
62
46
63
47
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
-
129
48
# setup: After running "venv" target, prepare that virtual environment with
130
49
# a local clone of cpython repository and the translation files.
131
50
# If the directories exists, only update the cpython repository and
132
51
# the translation files copy which could have new/updated files.
133
52
.PHONY : setup
134
53
setup : venv
135
- # Setup the main clone
136
54
git submodule sync
137
55
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/ \
153
56
154
57
155
58
# venv: create a virtual environment which will be used by almost every
156
59
# other target of this script
157
60
.PHONY : venv
158
61
venv :
159
- if [ ! -d $( VENV) ]; then \
62
+ if [ ! -d $( VENV) ]; then \
160
63
$(PYTHON ) -m venv --prompt $(LANGUAGE_TEAM ) $(VENV ) ; \
161
64
fi
162
65
163
66
$(VENV)/bin/python -m pip install -q -r requirements.txt 2> $(VENV)/pip-install.log
164
67
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 \
166
70
$(VENV)/bin/pip install -q --upgrade pip; \
167
71
fi
168
72
@@ -174,28 +78,6 @@ serve:
174
78
$(MAKE ) -C $(CPYTHON_WORKDIR ) /Doc serve
175
79
176
80
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
-
199
81
# clean: remove all .mo files and the venv directory that may exist and
200
82
# could have been created by the actions in other targets of this script
201
83
.PHONY : clean
@@ -207,3 +89,13 @@ clean:
207
89
.PHONY : progress
208
90
progress : venv
209
91
$(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