2017-10-13 20:39:17 +00:00
# Makefile for French Python Documentation
#
# Here is what you can do:
#
# - make # Automatically build an html local version
# - make todo # To list remaining tasks
2019-03-30 08:30:23 +00:00
# - make verifs # To check for correctness: wrapping, spelling
# - make powrap # To check for wrapping
# - make pospell # To check for spelling
2017-10-13 20:39:17 +00:00
# - make merge # To merge pot from upstream
# - make fuzzy # To find fuzzy strings
# - make progress # To compute current progression
2018-03-12 22:27:55 +00:00
# - make upgrade_venv # To upgrade the venv that compiles the doc
2017-10-13 20:39:17 +00:00
#
# 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.
CPYTHON_CLONE := ../cpython/
SPHINX_CONF := $( CPYTHON_CLONE) /Doc/conf.py
LANGUAGE := fr
VENV := ~/.venvs/python-docs-i18n/
PYTHON := $( shell which python3)
2018-11-14 20:47:36 +00:00
MODE := html
2019-09-04 09:33:01 +00:00
BRANCH = 3.8
2018-10-20 11:13:44 +00:00
COMMIT =
2018-11-04 21:05:00 +00:00
JOBS = auto
2017-10-13 20:39:17 +00:00
.PHONY : all
2018-09-21 19:50:56 +00:00
all : $( SPHINX_CONF ) $( VENV ) /bin /activate
2018-09-21 20:13:56 +00:00
i f n e q "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
2018-11-04 21:05:00 +00:00
$( warning " Your ../cpython checkout may be on the wrong branch, got $( shell cd $( CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD) expected $( BRANCH) " )
2018-09-21 20:13:56 +00:00
e n d i f
2018-07-23 12:55:58 +00:00
mkdir -p $( CPYTHON_CLONE) /locales/$( LANGUAGE) /
2018-09-21 20:14:10 +00:00
ln -nfs $( shell $( PYTHON) -c 'import os; print(os.path.realpath("."))' ) $( CPYTHON_CLONE) /locales/$( LANGUAGE) /LC_MESSAGES
2019-11-15 14:09:14 +00:00
$( MAKE) -C $( CPYTHON_CLONE) /Doc/ VENVDIR = $( VENV) PYTHON = $( PYTHON) \
SPHINXOPTS = '-qW -j$(JOBS) -D locale_dirs=../locales -D language=$(LANGUAGE) -D gettext_compact=0 -D latex_engine=xelatex -D latex_elements.inputenc= -D latex_elements.fontenc=' \
$( MODE) && echo " Build success, files in $( CPYTHON_CLONE) Doc/build/ $( MODE) , run 'make serve' or 'python3 -m http.server -d $( CPYTHON_CLONE) Doc/build/ $( MODE) ' to see them. "
.PHONY : serve
serve :
$( MAKE) -C $( CPYTHON_CLONE) /Doc/ serve
2017-10-13 20:39:17 +00:00
$(SPHINX_CONF) :
2018-10-20 11:13:44 +00:00
git clone --depth 1 --branch $( BRANCH) https://github.com/python/cpython.git $( CPYTHON_CLONE)
2018-11-09 19:21:10 +00:00
[ -n " $( COMMIT) " ] && ( i = 1; while ! $$ ( git -C $( CPYTHON_CLONE) checkout $( COMMIT) ) ; do i = $$ ( ( i * 2) ) ; git -C $( CPYTHON_CLONE) fetch --depth $$ i; done ) || true
2017-10-13 20:39:17 +00:00
2018-03-12 22:27:55 +00:00
.PHONY : upgrade_venv
2018-09-21 19:50:56 +00:00
upgrade_venv :
$( MAKE) -C $( CPYTHON_CLONE) /Doc/ VENVDIR = $( VENV) PYTHON = $( PYTHON) venv
2019-08-20 09:40:56 +00:00
$( VENV) /bin/pip install -U pip potodo powrap pospell
2018-03-12 22:27:55 +00:00
2019-02-21 19:34:00 +00:00
$(VENV)/bin/activate : $( SPHINX_CONF )
2018-10-05 15:17:46 +00:00
$( MAKE) -C $( CPYTHON_CLONE) /Doc/ VENVDIR = $( VENV) PYTHON = $( PYTHON) venv
2018-08-01 12:57:26 +00:00
2017-10-13 20:39:17 +00:00
.PHONY : progress
progress :
@python3 -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
2017-10-26 15:34:21 +00:00
$( shell msgcat *.po */*.po | msgattrib --translated | grep -c '^msgid' ) \
$( shell msgcat *.po */*.po | grep -c '^msgid' )
2017-10-13 20:39:17 +00:00
2019-01-16 23:40:37 +00:00
$(VENV)/bin/potodo : $( VENV ) /bin /activate
$( VENV) /bin/pip install potodo
2019-03-30 08:30:23 +00:00
$(VENV)/bin/powrap : $( VENV ) /bin /activate
$( VENV) /bin/pip install powrap
$(VENV)/bin/pospell : $( VENV ) /bin /activate
$( VENV) /bin/pip install pospell
2017-10-13 20:39:17 +00:00
.PHONY : todo
2019-01-16 23:40:37 +00:00
todo : $( VENV ) /bin /potodo
2019-04-11 22:21:53 +00:00
$( VENV) /bin/potodo
2017-10-13 20:39:17 +00:00
2019-03-30 08:30:23 +00:00
.PHONY : verifs
verifs : powrap pospell
.PHONY : powrap
powrap : $( VENV ) /bin /powrap
2019-11-02 09:26:49 +00:00
$( VENV) /bin/powrap --check --quiet *.po **/*.po
2019-03-30 08:30:23 +00:00
.PHONY : pospell
pospell : $( VENV ) /bin /pospell
2019-11-02 09:26:49 +00:00
$( VENV) /bin/pospell -p dict -l fr_FR *.po **/*.po
2019-03-30 08:30:23 +00:00
2017-10-13 20:39:17 +00:00
.PHONY : merge
2018-05-05 22:41:49 +00:00
merge : upgrade_venv
2017-10-13 21:07:23 +00:00
i f n e q "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
2018-06-28 13:32:56 +00:00
$( error "You're merging from a different branch:" " $( shell cd $( CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD) " vs " $( BRANCH) " )
2017-10-13 20:39:17 +00:00
e n d i f
2018-05-01 22:09:15 +00:00
( cd $( CPYTHON_CLONE) /Doc; rm -f build/NEWS)
2017-10-13 20:39:17 +00:00
( cd $( CPYTHON_CLONE) ; $( VENV) /bin/sphinx-build -Q -b gettext -D gettext_compact = 0 Doc pot/)
find $( CPYTHON_CLONE) /pot/ -name '*.pot' | \
while read -r POT; \
do \
PO = " ./ $$ (echo " $$ POT" | sed " s#$( CPYTHON_CLONE) /pot/##; s#\. pot\$ $# .po#")" ; \
mkdir -p " $$ (dirname " $$ PO")" ; \
if [ -f " $$ PO " ] ; \
then \
2018-05-01 22:09:15 +00:00
case " $$ POT " in\
*whatsnew*) msgmerge --backup= off --force-po --no-fuzzy-matching -U " $$ PO " " $$ POT " ; ; \
*) msgmerge --backup= off --force-po -U " $$ PO " " $$ POT " ; ; \
esac \
2017-10-13 20:39:17 +00:00
else \
msgcat -o " $$ PO " " $$ POT " ; \
fi \
done
.PHONY : fuzzy
2019-01-16 23:40:37 +00:00
fuzzy : $( VENV ) /bin /potodo
2019-08-20 09:40:56 +00:00
$( VENV) /bin/potodo -f