22#
33# Here is what you can do:
44#
5- # - make # Automatically build an html local version
5+ # - makeall # Automatically build an html local version
66# - make todo # To list remaining tasks
77# - make merge # To merge pot from upstream
88# - make fuzzy # To find fuzzy strings
1515#
1616# Credits: Python Documentation French Translation Team (https://github.com/python/python-docs-fr)
1717
18+ .DEFAULT_GOAL := help# Sets default action to be help
19+
20+ define PRINT_HELP_PYSCRIPT # start of Python section
21+ import re, sys
22+
23+ output = []
24+ # Loop through the lines in this file
25+ for line in sys.stdin:
26+ # if the line has a command and a comment start with
27+ # two pound signs, add it to the output
28+ match = re.match(r'^([a-zA-Z_-]+):.*?# # (.*)$$', line)
29+ if match:
30+ target, help = match.groups()
31+ output.append("%-10s %s" % (target, help))
32+ # Sort the output in alphanumeric order
33+ output.sort()
34+ # Print the help result
35+ print('\n'.join(output))
36+ endef
37+ export PRINT_HELP_PYSCRIPT # End of python section
38+
1839CPYTHON_CLONE := ../cpython/
1940SPHINX_CONF :=$(CPYTHON_CLONE ) /Doc/conf.py
2041LANGUAGE := zh_TW
@@ -25,16 +46,17 @@ MODE := autobuild-dev-html
2546BRANCH :=$(or $(VERSION ) ,$(shell git describe --contains --all HEAD) )
2647JOBS := 4
2748
28-
2949.PHONY : all
30- all :$(VENV ) /bin/sphinx-build$(VENV ) /bin/blurb clone
50+ all :$(VENV ) /bin/sphinx-build$(VENV ) /bin/blurb clone# # Automatically build an html local version
3151mkdir -p$(LC_MESSAGES )
3252for dirname in $$ (find. -name' *.po' | xargs -n1 dirname| sort -u| grep -v' ^\.$$' ); do mkdir -p$( LC_MESSAGES) /$$ dirname; done
3353for file in * .po* /* .po; do ln -f$$ file$( LC_MESSAGES) /$$ file; done
3454. $(VENV ) /bin/activate; $(MAKE ) -C$(CPYTHON_CLONE ) /Doc/ SPHINXOPTS=' -j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE )
3555
56+ help :
57+ @python3 -c" $$ PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST )
3658
37- clone :
59+ clone :# # Clone latest cpython repository to `../cpython/` if it doesn't exist
3860git clone --depth 1 --no-single-branch https://github.com/python/cpython.git$(CPYTHON_CLONE ) || echo " cpython exists"
3961cd $(CPYTHON_CLONE ) && git checkout$(BRANCH )
4062
@@ -53,24 +75,24 @@ $(VENV)/bin/blurb: $(VENV)/bin/activate
5375
5476
5577.PHONY : upgrade_venv
56- upgrade_venv :$(VENV ) /bin/activate
78+ upgrade_venv :$(VENV ) /bin/activate# # Upgrade the venv that compiles the doc
5779. $(VENV ) /bin/activate; python3 -m pip install --upgrade sphinx python-docs-theme blurb
5880
5981
6082.PHONY : progress
61- progress :
83+ progress :# # Compute current progression
6284@python3 -c' import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
6385$(shell msgcat* .po* /* .po | msgattrib --translated | grep -c '^msgid') \
6486$(shell msgcat* .po* /* .po | grep -c '^msgid')
6587
6688
6789.PHONY : todo
68- todo :
90+ todo :# # List remaining tasks
6991for file in * .po* /* .po; do echo $$ (msgattrib --untranslated$$ file| grep ^msgid| sed 1d| wc -l )$$ file; done | grep -v ^0| sort -gr
7092
7193
7294.PHONY : merge
73- merge : upgrade_venv
95+ merge : upgrade_venv# # To merge pot from upstream
7496ifneq "$(shell cd$(CPYTHON_CLONE ) 2>/dev/null && git describe --contains --all HEAD) " "$(BRANCH ) "
7597$(error "You're merging from a different branch")
7698endif
@@ -102,9 +124,9 @@ update_txconfig:
102124
103125
104126.PHONY : fuzzy
105- fuzzy :
127+ fuzzy :# # Find fuzzy strings
106128for file in * .po* /* .po; do echo $$ (msgattrib --only-fuzzy --no-obsolete" $$ file" | grep -c' #, fuzzy' )$$ file; done | grep -v ^0| sort -gr
107129
108130.PHONY : rm_cpython
109- rm_cpython :
131+ rm_cpython :# # Remove cloned cpython repo
110132rm -rf$(CPYTHON_CLONE )