Skip to content

Commit 39b6de3

Browse files
committed
Makefile to build and store some scripts.
1 parent 4580fb5 commit 39b6de3

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

Makefile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Makefile for French Python Documentation
2+
#
3+
# Here is what you can do:
4+
#
5+
# - make # Automatically build an html local version
6+
# - make todo # To list remaining tasks
7+
# - make merge # To merge pot from upstream
8+
# - make fuzzy # To find fuzzy strings
9+
# - make progress # To compute current progression
10+
#
11+
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
12+
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
13+
# real work to the Python Doc Makefile.
14+
15+
CPYTHON_CLONE := ../cpython/
16+
SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py
17+
LANGUAGE := fr
18+
VENV := ~/.venvs/python-docs-i18n/
19+
PYTHON := $(shell which python3)
20+
MODE := autobuild-dev-html
21+
BRANCH = $(shell git describe --contains --all HEAD)
22+
23+
24+
.PHONY: all
25+
all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb $(SPHINX_CONF)
26+
mkdir -p $(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/
27+
ln -nfs $(readlink -f .) $(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/LC_MESSAGES
28+
. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-D locale_dirs=$(CPYTHON_CLONE)/Doc/locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE)
29+
30+
31+
$(SPHINX_CONF):
32+
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git $(CPYTHON_CLONE)
33+
34+
35+
$(VENV)/bin/activate:
36+
mkdir -p $(VENV)
37+
$(PYTHON) -m venv $(VENV)
38+
39+
40+
$(VENV)/bin/sphinx-build: $(VENV)/bin/activate
41+
. $(VENV)/bin/activate; python3 -m pip install sphinx
42+
43+
44+
$(VENV)/bin/blurb: $(VENV)/bin/activate
45+
. $(VENV)/bin/activate; python3 -m pip install blurb
46+
47+
48+
.PHONY: progress
49+
progress:
50+
@python3 -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
51+
$(shell msgcat **/*.po | msgattrib --translated | grep -c '^msgid') \
52+
$(shell msgcat **/*.po | grep -c '^msgid')
53+
54+
55+
.PHONY: todo
56+
todo:
57+
for file in *.po */*.po; do echo $$(msgattrib --untranslated $$file | grep ^msgid | sed 1d | wc -l ) $$file; done | grep -v ^0 | sort -gr
58+
59+
60+
.PHONY: merge
61+
merge: $(VENV)/bin/sphinx-build
62+
ifneq "$(shell cd $(CPYTHON_CLONE); git describe --contains --all HEAD)" "$(BRANCH)"
63+
$(error "You're merging from a different branch")
64+
endif
65+
(cd $(CPYTHON_CLONE); $(VENV)/bin/sphinx-build -Q -b gettext -D gettext_compact=0 Doc pot/)
66+
find $(CPYTHON_CLONE)/pot/ -name '*.pot' |\
67+
while read -r POT;\
68+
do\
69+
PO="./$$(echo "$$POT" | sed "s#$(CPYTHON_CLONE)/pot/##; s#\.pot\$$#.po#")";\
70+
mkdir -p "$$(dirname "$$PO")";\
71+
if [ -f "$$PO" ];\
72+
then\
73+
msgmerge --backup=off --force-po -U "$$PO" "$$POT";\
74+
else\
75+
msgcat -o "$$PO" "$$POT";\
76+
fi\
77+
done
78+
79+
80+
.PHONY: fuzzy
81+
fuzzy:
82+
find -name '*.po' | xargs -L1 msgattrib --only-fuzzy --no-obsolete

0 commit comments

Comments
 (0)