-
-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathMakefile
More file actions
227 lines (193 loc) · 6.93 KB
/
Makefile
File metadata and controls
227 lines (193 loc) · 6.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Makefile for French Python Documentation
#
# Here is what you can do:
#
# - make # Automatically build an HTML local version
# - make todo # To list remaining tasks and show current progression
# - make check # To check for correctness of modified files: wrapping, spelling, …
# - make check-all # To check for correctness of all files: wrapping, spelling, …
# - make wrap # To rewrap modified files
# - make spell # To check for spelling
# - make clean # To remove build artifacts
# - make fuzzy # To find fuzzy strings
#
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
# real work to the Python Doc Makefile.
# Configuration
# The CPYTHON_CURRENT_COMMIT is the commit, in the cpython repository,
# from which we generated our po files. We use it here so when we
# test build, we're building with the .rst files that generated our
# .po files.
CPYTHON_CURRENT_COMMIT := 5513f6a99d3dc05b93f92c740484a607ef7c0cbf
LANGUAGE := fr
BRANCH := 3.14
EXCLUDED := \
whatsnew/2.?.po \
whatsnew/3.[0-8].po \
c-api/ \
distutils/ \
install/ \
library/2to3.po \
library/distutils.po \
library/imp.po \
library/tkinter.tix.po \
library/test.po \
library/aifc.po \
library/asynchat.po \
library/asyncore.po \
library/audioop.po \
library/cgi.po \
library/cgitb.po \
library/chunk.po \
library/crypt.po \
library/imghdr.po \
library/msilib.po \
library/nntplib.po \
library/nis.po \
library/ossaudiodev.po \
library/pipes.po \
library/smtpd.po \
library/sndhdr.po \
library/spwd.po \
library/sunau.po \
library/telnetlib.po \
library/uu.po \
library/xdrlib.po
# Internal variables
UPSTREAM := https://github.com/python/cpython
PYTHON := $(shell which python3)
MODE := html
MAKE_TMP_DIR := .make/
JOBS := auto
SPHINXERRORHANDLING = -W
# Detect OS
ifeq '$(findstring ;,$(PATH))' ';'
detected_OS := Windows
else
detected_OS := $(shell uname 2>/dev/null || echo Unknown)
detected_OS := $(patsubst CYGWIN%,Cygwin,$(detected_OS))
detected_OS := $(patsubst MSYS%,MSYS,$(detected_OS))
detected_OS := $(patsubst MINGW%,MSYS,$(detected_OS))
endif
ifeq ($(detected_OS),Darwin) # Mac OS X
CP_CMD := gcp # accessible with `brew install coreutils` or `brew upgrade coreutils`
else
CP_CMD := cp
endif
.PHONY: all
all: ensure_build_prerequisites
git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT) || (git -C venv/cpython fetch && git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT))
mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/
$(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/
$(MAKE) -C venv/cpython/Doc/ \
JOBS='$(JOBS)' \
SPHINXOPTS='-D locale_dirs=$(abspath locales) \
-D language=$(LANGUAGE) \
-D gettext_compact=0 \
-D latex_engine=xelatex \
-D latex_elements.inputenc= \
-D latex_elements.fontenc=' \
SPHINXERRORHANDLING=$(SPHINXERRORHANDLING) \
$(MODE)
@echo "Build success, open file://$(abspath venv/cpython/)/Doc/build/html/index.html or run 'make htmlview' to see them."
# We clone cpython/ inside venv/ because venv/ is the only directory
# excluded by cpython' Sphinx configuration.
venv/cpython/.git/HEAD:
git clone https://github.com/python/cpython venv/cpython
.PHONY: ensure_test_prerequisites
ensure_test_prerequisites:
@if ! (hunspell -v >/dev/null 2>&1); then \
echo "You're missing dependencies please install: hunspell and the fr-toutesvariantes dictionary."; \
echo "The dictionary is available here http://grammalecte.net:8080/dir?ci=tip&name=gc_lang/fr/oxt/Dictionnaires/dictionaries"; \
echo "and also included in the hunspell-fr-comprehensive Debian package."; \
exit 1; \
fi
@if ! (pospell --help >/dev/null 2>&1 && potodo --help >/dev/null 2>&1); then \
echo "You're missing dependencies please install:"; \
echo ""; \
echo " python -m pip install -r requirements.txt"; \
exit 1; \
fi
.PHONY: ensure_build_prerequisites
ensure_build_prerequisites: venv/cpython/.git/HEAD
@if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \
git -C venv/cpython/ checkout $(BRANCH); \
echo "You're missing dependencies please install:"; \
echo ""; \
echo " python -m pip install -r venv/cpython/Doc/requirements.txt"; \
exit 1; \
fi
.PHONY: htmlview
htmlview: MODE=htmlview
htmlview: all
.PHONY: todo
todo: ensure_test_prerequisites
@potodo --api-url 'https://git.afpy.org/api/v1/repos/AFPy/python-docs-fr/issues?state=open' --exclude venv .venv $(EXCLUDED)
.PHONY: wrap
wrap: ensure_test_prerequisites
@echo "Re wrapping modified files"
powrap -m
SRCS_MODIFIED = $(shell git diff --name-only --diff-filter=d $(BRANCH) | grep '.po$$')
SRCS_ALL = $(wildcard *.po */*.po)
# foo/bar.po => $(MAKE_TMP_DIR)/foo/bar.po.out
DESTS_MODIFIED = $(addprefix $(MAKE_TMP_DIR)/,$(addsuffix .pospell,$(SRCS_MODIFIED)))
DESTS_ALL = $(addprefix $(MAKE_TMP_DIR)/,$(addsuffix .all,$(SRCS_ALL)))
.PHONY: spell
spell: ensure_test_prerequisites $(DESTS_MODIFIED)
.PHONY: line-length
line-length:
@echo Checking line length...
@if [ -n "$(SRCS_MODIFIED)" ]; then python .scripts/line-length.py $(SRCS_MODIFIED); fi
.PHONY: sphinx-lint
sphinx-lint: ensure_test_prerequisites
@echo Checking reStructuredText syntax...
@if [ -n "$(SRCS_MODIFIED)" ]; then sphinx-lint --enable all --disable line-too-long $(SRCS_MODIFIED); fi
$(MAKE_TMP_DIR)/%.po.pospell: %.po dict
@echo "Pospell checking $<..."
@mkdir -p $(@D)
pospell -p dict -l fr_FR $<
@touch $@
$(MAKE_TMP_DIR)/%.po.all: %.po dict
@mkdir -p $(@D)
@msgcat $< >/dev/null
@python .scripts/line-length.py $<
@sh .scripts/check-headers.sh $<
@pospell -p dict -l fr_FR $<
@sphinx-lint --enable all --disable line-too-long $< >/dev/null
@touch $@
.PHONY: fuzzy
fuzzy: ensure_test_prerequisites
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)
.PHONY: check-headers
check-headers:
@echo Checking po headers...
@sh .scripts/check-headers.sh $(SRCS_MODIFIED)
# .PHONY: check-colons
# check-colons:
# @echo Checking colons...
# @python .scripts/check-colon.py --check $(SRCS_MODIFIED)
.PHONY: syntax
syntax:
@echo Checking po sytax...
@msgcat *.po */*.po > /dev/null
.PHONY: verifs
verifs: syntax check-headers sphinx-lint spell line-length
@echo "'make verifs' is deprecated, please use 'make check' instead."
.PHONY: check
check: syntax check-headers sphinx-lint spell line-length
.PHONY: check-all
check-all: ensure_test_prerequisites $(DESTS_ALL)
.PHONY: clean
clean:
@echo "Cleaning *.mo and $(MAKE_TMP_DIR)"
rm -fr .pospell/ $(MAKE_TMP_DIR) locales/$(LANGUAGE)/LC_MESSAGES/
find -name '*.mo' -delete
@echo "Cleaning build directory"
$(MAKE) -C venv/cpython/Doc/ clean
.PHONY: diff
diff:
@echo "Files changed between $(BRANCH) and HEAD:"
@echo $(shell git diff --name-only --diff-filter=d $(BRANCH))
print-%:
@echo $($*)