3
3
# Here is what you can do:
4
4
#
5
5
# - make # Automatically build an HTML local version
6
- # - make todo # To list remaining tasks
6
+ # - make todo # To list remaining tasks and show current progression
7
7
# - make verifs # To check for correctness: wrapping, spelling
8
- # - make wrap # To check for wrapping
8
+ # - make wrap # To rewrap modified files
9
9
# - make spell # To check for spelling
10
- # - make merge # To merge pot from upstream
10
+ # - make clean # To remove build artifacts
11
11
# - make fuzzy # To find fuzzy strings
12
- # - make progress # To compute current progression
13
12
#
14
13
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
15
14
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
22
21
# test build, we're building with the .rst files that generated our
23
22
# .po files.
24
23
CPYTHON_CURRENT_COMMIT := cb0b009cfb4ae2a87a8737250c526b8f95d0551f
25
-
26
- CPYTHON_PATH := ../cpython/
27
-
28
24
LANGUAGE := fr
29
25
BRANCH := 3.9
30
26
31
- EXCLUDED := whatsnew/ c-api/
27
+ EXCLUDED := \
28
+ whatsnew/2.?.po \
29
+ whatsnew/3.[0-8].po \
30
+ c-api/ \
31
+ distutils/ \
32
+ install/ \
33
+ library/2to3.po \
34
+ library/distutils.po \
35
+ library/imp.po \
36
+ library/tkinter.tix.po \
37
+ library/test.po \
38
+ library/aifc.po \
39
+ library/asynchat.po \
40
+ library/asyncore.po \
41
+ library/audioop.po \
42
+ library/cgi.po \
43
+ library/cgitb.po \
44
+ library/chunk.po \
45
+ library/crypt.po \
46
+ library/imghdr.po \
47
+ library/msilib.po \
48
+ library/nntplib.po \
49
+ library/nis.po \
50
+ library/ossaudiodev.po \
51
+ library/pipes.po \
52
+ library/smtpd.po \
53
+ library/sndhdr.po \
54
+ library/spwd.po \
55
+ library/sunau.po \
56
+ library/telnetlib.po \
57
+ library/uu.po \
58
+ library/xdrlib.po
32
59
33
60
# Internal variables
34
61
@@ -38,6 +65,7 @@ PYTHON := $(shell which python3)
38
65
MODE := html
39
66
POSPELL_TMP_DIR := .pospell/
40
67
JOBS := auto
68
+ SPHINXERRORHANDLING = -W
41
69
42
70
# Detect OS
43
71
@@ -58,69 +86,50 @@ endif
58
86
59
87
.PHONY : all
60
88
all : ensure_prerequisites
61
- git -C $( CPYTHON_PATH ) checkout $(CPYTHON_CURRENT_COMMIT )
89
+ git -C venv/cpython checkout $( CPYTHON_CURRENT_COMMIT ) || (git -C venv/cpython fetch && git -C venv/cpython checkout $( CPYTHON_CURRENT_COMMIT) )
62
90
mkdir -p locales/$(LANGUAGE ) /LC_MESSAGES/
63
91
$(CP_CMD ) -u --parents * .po * /* .po locales/$(LANGUAGE ) /LC_MESSAGES/
64
- $(MAKE ) -C $( CPYTHON_PATH ) / Doc/ \
65
- SPHINXOPTS= ' -W -j $(JOBS) \
66
- -D locale_dirs=$(abspath locales) \
92
+ $(MAKE ) -C venv/cpython/ Doc/ \
93
+ JOBS= ' $(JOBS)' \
94
+ SPHINXOPTS= ' -D locale_dirs=$(abspath locales) \
67
95
-D language=$(LANGUAGE ) \
68
- -D gettext_compact=0 \
96
+ -D gettext_compact=0 \
69
97
-D latex_engine=xelatex \
70
98
-D latex_elements.inputenc= \
71
99
-D latex_elements.fontenc=' \
100
+ SPHINXERRORHANDLING=$(SPHINXERRORHANDLING ) \
72
101
$(MODE )
73
- @echo " Build success, open file://$( abspath $( CPYTHON_PATH) ) /Doc/build/html/index.html or run 'make serve' to see them."
102
+ @echo " Build success, open file://$( abspath venv/cpython/) /Doc/build/html/index.html or run 'make htmlview' to see them."
103
+
104
+
105
+ # We clone cpython/ inside venv/ because venv/ is the only directory
106
+ # excluded by cpython' Sphinx configuration.
107
+ venv/cpython/.git/HEAD :
108
+ git clone https://github.com/python/cpython venv/cpython
74
109
75
110
76
111
.PHONY : ensure_prerequisites
77
- ensure_prerequisites :
78
- @if [ -z $( CPYTHON_PATH) ]; then \
79
- echo " Your CPYTHON_PATH is empty, please provide one." ; \
80
- exit 1; \
81
- fi
82
- @if ! [ -d $( CPYTHON_PATH) ]; then \
83
- echo " Building the translation requires a cpython clone." ; \
84
- echo " Please provide the path to a clone using the CPYTHON_PATH variable." ; \
85
- echo " (Currently CPYTHON_PATH is $( CPYTHON_PATH) ." ; \
86
- echo " So you may want to run:" ; \
87
- echo " " ; \
88
- echo " git clone $( UPSTREAM) $( CPYTHON_PATH) " ; \
89
- exit 1; \
90
- fi
91
- @if [ -n " $$ (git -C $( CPYTHON_PATH) status --porcelain)" ]; then \
92
- echo " Your cpython clone at $( CPYTHON_PATH) is not clean." ; \
93
- echo " In order to avoid breaking things, please clean it first." ; \
94
- exit 1; \
95
- fi
112
+ ensure_prerequisites : venv/cpython/.git/HEAD
96
113
@if ! (blurb help > /dev/null 2>&1 && sphinx-build --version > /dev/null 2>&1 ); then \
97
- git -C $( CPYTHON_PATH ) checkout $(BRANCH ) ; \
98
- echo " You're missing dependencies, please enable a venv and install:" ; \
114
+ git -C venv/cpython/ checkout $(BRANCH ) ; \
115
+ echo " You're missing dependencies please install:" ; \
99
116
echo " " ; \
100
- echo " python -m pip install -r requirements.txt -r $( CPYTHON_PATH ) /Doc/requirements.txt" ; \
117
+ echo " python -m pip install -r requirements.txt -r venv/cpython /Doc/requirements.txt" ; \
101
118
exit 1; \
102
119
fi
103
120
104
- .PHONY : serve
105
- serve :
106
- $(MAKE ) -C $(CPYTHON_PATH ) /Doc/ serve
107
-
108
-
109
- .PHONY : progress
110
- progress :
111
- @$(PYTHON ) -c ' import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
112
- $(shell msgcat * .po * /* .po | msgattrib --translated | grep -c '^msgid') \
113
- $(shell msgcat * .po * /* .po | grep -c '^msgid')
114
-
121
+ .PHONY : htmlview
122
+ htmlview : MODE=htmlview
123
+ htmlview : all
115
124
116
125
.PHONY : todo
117
126
todo : ensure_prerequisites
118
- potodo --exclude venv .venv $(EXCLUDED )
127
+ potodo --api-url ' https://git.afpy.org/api/v1/repos/AFPy/python-docs-fr/issues?state=open&type=issues ' -- exclude venv .venv $(EXCLUDED )
119
128
120
129
.PHONY : wrap
121
130
wrap : ensure_prerequisites
122
- @echo " Verify wrapping"
123
- powrap --check --quiet * .po ** / * .po
131
+ @echo " Re wrapping modified files "
132
+ powrap -m
124
133
125
134
SRCS = $(shell git diff --name-only $(BRANCH ) | grep '.po$$')
126
135
# foo/bar.po => $(POSPELL_TMP_DIR)/foo/bar.po.out
@@ -129,44 +138,51 @@ DESTS = $(addprefix $(POSPELL_TMP_DIR)/,$(addsuffix .out,$(SRCS)))
129
138
.PHONY : spell
130
139
spell : ensure_prerequisites $(DESTS )
131
140
141
+ .PHONY : line-length
142
+ line-length :
143
+ @echo " Searching for long lines..."
144
+ @awk ' {if (length(gensub(/శ్రీనివాస్/, ".", "g", $$0)) > 80 && length(gensub(/[^ ]/, "", "g")) > 1) {print FILENAME ":" FNR, "line too long:", $$0; ERRORS+=1}} END {if (ERRORS>0) {exit 1}}' * .po * /* .po
145
+
146
+ .PHONY : sphinx-lint
147
+ sphinx-lint :
148
+ @echo " Checking all files using sphinx-lint..."
149
+ @sphinx-lint --enable all --disable line-too-long * .po * /* .po
150
+
132
151
$(POSPELL_TMP_DIR ) /% .po.out : % .po dict
133
152
@echo " Pospell checking $<..."
134
- mkdir -p $(@D )
153
+ @ mkdir -p $(@D )
135
154
pospell -p dict -l fr_FR $< && touch $@
136
155
137
156
.PHONY : fuzzy
138
157
fuzzy : ensure_prerequisites
139
- potodo -f --exclude venv .venv $(EXCLUDED )
158
+ potodo --only-fuzzy --api-url ' https://git.afpy.org/api/v1/repos/AFPy/python-docs-fr/issues?state=open&type=issues' --exclude venv .venv $(EXCLUDED )
159
+
160
+ .PHONY : check-headers
161
+ check-headers :
162
+ @grep -L ' ^# Copyright (C) [0-9-]*, Python Software Foundation' * .po * /* .po | while read -r file; \
163
+ do \
164
+ echo " Please update the po comment in $$ file" ; \
165
+ done
166
+ @grep -L ' ^"Project-Id-Version: Python 3\\n"$$' * .po * /* .po | while read -r file; \
167
+ do \
168
+ echo " Please update the 'Project-Id-Version' header in $$ file" ; \
169
+ done
170
+ @grep -L ' ^"Language: fr\\n"$$' * .po * /* .po | while read -r file; \
171
+ do \
172
+ echo " Please update the 'Language' header in $$ file" ; \
173
+ done
174
+ @grep -L ' ^"Language-Team: FRENCH <traductions@lists.afpy.org>\\n"' * .po * /* .po | while read -r file; \
175
+ do \
176
+ echo " Please update the 'Language-Team' header in $$ file" ; \
177
+ done
140
178
141
179
.PHONY : verifs
142
- verifs : wrap spell
143
-
144
- .PHONY : merge
145
- merge : ensure_prerequisites
146
- @echo " Merge from $( UPSTREAM) "
147
- git -C $(CPYTHON_PATH ) checkout $(BRANCH )
148
- git -C $(CPYTHON_PATH ) pull --ff-only
149
- (cd $( CPYTHON_PATH) /Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot)
150
- find $(CPYTHON_PATH ) /pot/ -name ' *.pot' | \
151
- while read -r POT; \
152
- do \
153
- PO=" ./$$ (echo " $$ POT" | sed " s#$(CPYTHON_PATH ) /pot/# #; s#\.pot\$$#.po#")"; \
154
- mkdir -p " $$ (dirname " $$ PO" )" ; \
155
- if [ -f " $$ PO" ]; \
156
- then \
157
- msgmerge --backup=off --force-po -U " $$ PO" " $$ POT" ; \
158
- else \
159
- msgcat -o " $$ PO" " $$ POT" ; \
160
- fi \
161
- done
162
- rm -fr $(CPYTHON_PATH ) /pot/
163
- sed -i ' s|^#: .*Doc/|#: |' * .po * /* .po
164
- powrap -m
165
- @printf " \n%s %s\n" " Replace CPYTHON_CURRENT_COMMIT in Makefile by: " $(shell git -C $(CPYTHON_PATH ) rev-parse HEAD)
166
- @printf ' To add, you can use:\n git status -s | grep "^ M .*\.po" | cut -d" " -f3 | while read -r file; do if [ $$(git diff "$$file" | wc -l) -gt 13 ]; then git add "$$file"; fi ; done\n'
180
+ verifs : spell line-length sphinx-lint check-headers
167
181
168
182
.PHONY : clean
169
183
clean :
170
184
@echo " Cleaning *.mo and $( POSPELL_TMP_DIR) "
171
- rm -fr $(POSPELL_TMP_DIR )
185
+ rm -fr $(POSPELL_TMP_DIR ) locales/ $( LANGUAGE ) /LC_MESSAGES/
172
186
find -name ' *.mo' -delete
187
+ @echo " Cleaning build directory"
188
+ $(MAKE ) -C venv/cpython/Doc/ clean
0 commit comments