2
2
#
3
3
# Here is what you can do:
4
4
#
5
- # - make # Automatically build an html local version
5
+ # - make all # Automatically build an html local version
6
6
# - make todo # To list remaining tasks
7
7
# - make merge # To merge pot from upstream
8
8
# - make fuzzy # To find fuzzy strings
15
15
#
16
16
# Credits: Python Documentation French Translation Team (https://github.com/python/python-docs-fr)
17
17
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
+
18
39
CPYTHON_CLONE := ../cpython/
19
40
SPHINX_CONF := $(CPYTHON_CLONE ) /Doc/conf.py
20
41
LANGUAGE := zh_TW
@@ -25,16 +46,17 @@ MODE := autobuild-dev-html
25
46
BRANCH := $(or $(VERSION ) , $(shell git describe --contains --all HEAD) )
26
47
JOBS := 4
27
48
28
-
29
49
.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
31
51
mkdir -p $(LC_MESSAGES )
32
52
for dirname in $$ (find . -name ' *.po' | xargs -n1 dirname | sort -u | grep -v ' ^\.$$' ); do mkdir -p $( LC_MESSAGES) /$$ dirname; done
33
53
for file in * .po * /* .po; do ln -f $$ file $( LC_MESSAGES) /$$ file; done
34
54
. $(VENV ) /bin/activate; $(MAKE ) -C $(CPYTHON_CLONE ) /Doc/ SPHINXOPTS=' -j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE )
35
55
56
+ help :
57
+ @python3 -c " $$ PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST )
36
58
37
- clone :
59
+ clone : # # Clone latest cpython repository to `../cpython/` if it doesn't exist
38
60
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git $(CPYTHON_CLONE ) || echo " cpython exists"
39
61
cd $(CPYTHON_CLONE ) && git checkout $(BRANCH )
40
62
@@ -53,24 +75,24 @@ $(VENV)/bin/blurb: $(VENV)/bin/activate
53
75
54
76
55
77
.PHONY : upgrade_venv
56
- upgrade_venv : $(VENV ) /bin/activate
78
+ upgrade_venv : $(VENV ) /bin/activate # # Upgrade the venv that compiles the doc
57
79
. $(VENV ) /bin/activate; python3 -m pip install --upgrade sphinx python-docs-theme blurb
58
80
59
81
60
82
.PHONY : progress
61
- progress :
83
+ progress : # # Compute current progression
62
84
@python3 -c ' import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
63
85
$(shell msgcat * .po * /* .po | msgattrib --translated | grep -c '^msgid') \
64
86
$(shell msgcat * .po * /* .po | grep -c '^msgid')
65
87
66
88
67
89
.PHONY : todo
68
- todo :
90
+ todo : # # List remaining tasks
69
91
for file in * .po * /* .po; do echo $$ (msgattrib --untranslated $$ file | grep ^msgid | sed 1d | wc -l ) $$ file; done | grep -v ^0 | sort -gr
70
92
71
93
72
94
.PHONY : merge
73
- merge : upgrade_venv
95
+ merge : upgrade_venv # # To merge pot from upstream
74
96
ifneq "$(shell cd $(CPYTHON_CLONE ) 2>/dev/null && git describe --contains --all HEAD) " "$(BRANCH ) "
75
97
$(error "You're merging from a different branch")
76
98
endif
@@ -102,9 +124,9 @@ update_txconfig:
102
124
103
125
104
126
.PHONY : fuzzy
105
- fuzzy :
127
+ fuzzy : # # Find fuzzy strings
106
128
for file in * .po * /* .po; do echo $$ (msgattrib --only-fuzzy --no-obsolete " $$ file" | grep -c ' #, fuzzy' ) $$ file; done | grep -v ^0 | sort -gr
107
129
108
130
.PHONY : rm_cpython
109
- rm_cpython :
131
+ rm_cpython : # # Remove cloned cpython repo
110
132
rm -rf $(CPYTHON_CLONE )
0 commit comments