2017-10-13 20:39:17 +00:00
# Makefile for French Python Documentation
#
# Here is what you can do:
#
2021-01-27 18:23:53 +00:00
# - make # Automatically build an HTML local version
2017-10-13 20:39:17 +00:00
# - make todo # To list remaining tasks
2019-12-10 10:52:16 +00:00
# - make verifs # To check for correctness: wrapping, spelling
# - make wrap # To check for wrapping
# - make spell # 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
#
# 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.
2019-12-10 10:52:16 +00:00
# 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.
2021-03-19 16:27:36 +00:00
CPYTHON_CURRENT_COMMIT := eec8e61992fb654d4cf58de4d727c18622b8303e
2019-12-10 10:52:16 +00:00
2019-12-12 10:24:14 +00:00
CPYTHON_PATH := ../cpython/
2019-12-10 10:52:16 +00:00
2017-10-13 20:39:17 +00:00
LANGUAGE := fr
2020-06-05 07:32:47 +00:00
BRANCH := 3.9
2019-12-10 10:52:16 +00:00
2020-06-10 18:16:22 +00:00
EXCLUDED := whatsnew/ c-api/
2019-12-10 10:52:16 +00:00
# Internal variables
UPSTREAM := https://github.com/python/cpython
2021-01-27 18:23:53 +00:00
2017-10-13 20:39:17 +00:00
PYTHON := $( shell which python3)
2018-11-14 20:47:36 +00:00
MODE := html
2019-12-10 12:57:17 +00:00
POSPELL_TMP_DIR := .pospell/
2019-12-10 10:52:16 +00:00
JOBS := auto
2017-10-13 20:39:17 +00:00
2020-05-30 09:36:13 +00:00
# Detect OS
i f e q '$(findstring ;,$(PATH))' ';'
detected_OS := Windows
e l s e
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) )
e n d i f
i f e q ( $( detected_OS ) , D a r w i n ) # Mac OS X
CP_CMD := gcp # accessible with `brew install coreutils` or `brew upgrade coreutils`
e l s e
CP_CMD := cp
e n d i f
2017-10-13 20:39:17 +00:00
.PHONY : all
2021-01-27 18:23:53 +00:00
all : ensure_prerequisites
git -C $( CPYTHON_PATH) checkout $( CPYTHON_CURRENT_COMMIT)
mkdir -p locales/$( LANGUAGE) /LC_MESSAGES/
$( CP_CMD) -u --parents *.po */*.po locales/$( LANGUAGE) /LC_MESSAGES/
$( MAKE) -C $( CPYTHON_PATH) /Doc/ \
2021-04-30 15:08:43 +00:00
SPHINXOPTS = ' -W -j$( JOBS) \
2021-01-27 18:23:53 +00:00
-D locale_dirs = $( abspath locales) \
-D language = $( LANGUAGE) \
-D gettext_compact = 0 \
-D latex_engine = xelatex \
-D latex_elements.inputenc= \
-D latex_elements.fontenc= ' \
$( MODE)
@echo " Build success, open file:// $( abspath $( CPYTHON_PATH) ) /Doc/build/html/index.html or run 'make serve' to see them. "
.PHONY : ensure_prerequisites
ensure_prerequisites :
@if [ -z $( CPYTHON_PATH) ] ; then \
echo "Your CPYTHON_PATH is empty, please provide one." ; \
exit 1; \
2019-12-10 10:52:16 +00:00
fi
2021-01-27 18:23:53 +00:00
@if ! [ -d $( CPYTHON_PATH) ] ; then \
echo "Building the translation requires a cpython clone." ; \
echo "Please provide the path to a clone using the CPYTHON_PATH variable." ; \
echo " (Currently CPYTHON_PATH is $( CPYTHON_PATH) . " ; \
echo "So you may want to run:" ; \
echo "" ; \
echo " git clone $( UPSTREAM) $( CPYTHON_PATH) " ; \
exit 1; \
2019-12-10 10:52:16 +00:00
fi
2021-01-27 18:23:53 +00:00
@if [ -n " $$ (git -C $( CPYTHON_PATH) status --porcelain) " ] ; then \
echo " Your cpython clone at $( CPYTHON_PATH) is not clean. " ; \
echo "In order to avoid breaking things, please clean it first." ; \
exit 1; \
fi
@if ! ( blurb help >/dev/null 2>& 1 && sphinx-build --version >/dev/null 2>& 1) ; then \
2021-03-24 21:59:41 +00:00
git -C $( CPYTHON_PATH) checkout $( BRANCH) ; \
2021-01-27 18:23:53 +00:00
echo "You're missing dependencies, please enable a venv and install:" ; \
echo "" ; \
echo " python -m pip install -r requirements.txt -r $( CPYTHON_PATH) /Doc/requirements.txt " ; \
exit 1; \
2019-12-12 08:30:09 +00:00
fi
2019-11-15 14:09:14 +00:00
.PHONY : serve
serve :
2021-01-27 18:23:53 +00:00
$( MAKE) -C $( CPYTHON_PATH) /Doc/ serve
2018-08-01 12:57:26 +00:00
2017-10-13 20:39:17 +00:00
.PHONY : progress
progress :
2021-01-27 18:23:53 +00:00
@$( PYTHON) -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
.PHONY : todo
2021-01-27 18:23:53 +00:00
todo : ensure_prerequisites
potodo --exclude venv .venv $( EXCLUDED)
2017-10-13 20:39:17 +00:00
2019-12-04 21:08:12 +00:00
.PHONY : wrap
2021-01-27 18:23:53 +00:00
wrap : ensure_prerequisites
@echo "Verify wrapping"
powrap --check --quiet *.po **/*.po
2019-03-30 08:30:23 +00:00
2019-12-10 12:57:17 +00:00
SRCS = $( shell git diff --name-only $( BRANCH) | grep '.po$$' )
# foo/bar.po => $(POSPELL_TMP_DIR)/foo/bar.po.out
DESTS = $( addprefix $( POSPELL_TMP_DIR) /,$( addsuffix .out,$( SRCS) ) )
2019-12-04 21:08:12 +00:00
.PHONY : spell
2021-01-27 18:23:53 +00:00
spell : ensure_prerequisites $( DESTS )
2019-12-10 12:57:17 +00:00
$(POSPELL_TMP_DIR)/%.po.out : %.po dict
2021-01-27 18:23:53 +00:00
@echo " Pospell checking $<... "
2020-05-21 13:18:51 +00:00
mkdir -p $( @D)
2021-01-27 18:23:53 +00:00
pospell -p dict -l fr_FR $< && touch $@
2019-03-30 08:30:23 +00:00
2019-12-10 10:52:16 +00:00
.PHONY : fuzzy
2021-01-27 18:23:53 +00:00
fuzzy : ensure_prerequisites
potodo -f --exclude venv .venv $( EXCLUDED)
2019-12-10 10:52:16 +00:00
.PHONY : verifs
verifs : wrap spell
2017-10-13 20:39:17 +00:00
.PHONY : merge
2021-01-27 18:23:53 +00:00
merge : ensure_prerequisites
@echo " Merge from $( UPSTREAM) "
git -C $( CPYTHON_PATH) checkout $( BRANCH)
git -C $( CPYTHON_PATH) pull --ff-only
( cd $( CPYTHON_PATH) /Doc; sphinx-build -Q -b gettext -D gettext_compact = 0 . ../pot)
find $( CPYTHON_PATH) /pot/ -name '*.pot' | \
while read -r POT; \
do \
PO = " ./ $$ (echo " $$ POT" | sed " s#$( CPYTHON_PATH) /pot/##; s#\. pot\$ $# .po#")" ; \
mkdir -p " $$ (dirname " $$ PO")" ; \
if [ -f " $$ PO " ] ; \
then \
msgmerge --backup= off --force-po -U " $$ PO " " $$ POT " ; \
else \
msgcat -o " $$ PO " " $$ POT " ; \
fi \
2017-10-13 20:39:17 +00:00
done
2021-01-27 18:23:53 +00:00
rm -fr $( CPYTHON_PATH) /pot/
2020-07-20 08:45:25 +00:00
sed -i 's|^#: .*Doc/|#: |' *.po */*.po
2021-01-27 18:23:53 +00:00
powrap -m
2021-03-19 16:27:36 +00:00
@printf "\n%s %s\n" "Replace CPYTHON_CURRENT_COMMIT in Makefile by: " $( shell git -C $( CPYTHON_PATH) rev-parse HEAD)
@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'
2019-12-10 10:52:16 +00:00
.PHONY : clean
clean :
2021-01-27 18:23:53 +00:00
@echo " Cleaning *.mo and $( POSPELL_TMP_DIR) "
rm -fr $( POSPELL_TMP_DIR)
2019-12-10 10:52:16 +00:00
find -name '*.mo' -delete