Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a30c43

Browse files
authored
fix(make): always link the build target (#913)
* fix(make): always link the build target* refactor(make): handle mkdir in more compact way* refactor(make): make 3.12 as default build version* refactor(make): organize preparation directives
1 parent0d02495 commit1a30c43

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

‎Makefile

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Here is what you can do:
44
#
55
# - make all # Automatically build an html local version
6-
# - make build # To build a single .po file
6+
# - make build<po-file> # To build a single .po file
77
# - make todo # To list remaining tasks
88
# - make merge # To merge pot from upstream
99
# - make fuzzy # To find fuzzy strings
@@ -37,25 +37,23 @@ print('\n'.join(output))
3737
endef
3838
exportPRINT_HELP_PYSCRIPT# End of python section
3939

40-
CPYTHON_CLONE := ../cpython/
40+
CPYTHON_CLONE := ../cpython
41+
VERSION :=$(or$(VERSION), 3.12)
4142
SPHINX_CONF :=$(CPYTHON_CLONE)/Doc/conf.py
4243
LANGUAGE := zh_TW
4344
LC_MESSAGES :=$(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/LC_MESSAGES
4445
VENV := ~/.venvs/python-docs-i18n/
45-
PYTHON :=$(shell which python3)
4646
MODE := autobuild-dev-html
47-
BRANCH :=$(or$(VERSION),$(shell git describe --contains --all HEAD))
4847
JOBS := 4
4948

5049
.PHONY: all
51-
all:$(VENV)/bin/sphinx-build$(VENV)/bin/blurb clone## Automatically build an html local version
52-
mkdir -p$(LC_MESSAGES)
50+
all: prepare_deps## Automatically build an html local version
5351
fordirnamein$$(find. -name'*.po'| xargs -n1 dirname| sort -u| grep -v'^\.$$');do mkdir -p$(LC_MESSAGES)/$$dirname;done
5452
forfilein*.po*/*.po;do ln -f$$file$(LC_MESSAGES)/$$file;done
5553
.$(VENV)/bin/activate;$(MAKE) -C$(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0'$(MODE)
5654

5755
.PHONY: build
58-
build:$(VENV)/bin/sphinx-build$(VENV)/bin/blurb clone## Automatically build an html local version
56+
build:prepare_deps## Automatically build an html local version for a single file
5957
@$(eval target=$(filter-out$@,$(MAKECMDGOALS)))
6058
@if [-z$(target) ];then\
6159
echo"\x1B[1;31m""Please provide a file argument.""\x1B[m";\
@@ -69,32 +67,29 @@ build: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build a
6967
echo"\x1B[1;31m""ERROR:$(target) not exist.""\x1B[m";\
7068
exit 1;\
7169
fi
72-
@mkdir -p$(LC_MESSAGES)
70+
7371
@$(eval dir=`echo $(target) | xargs -n1 dirname`)## Get dir
74-
# If the build target is in under directory
75-
# We should make direcotry in $(LC_MESSAGES) and link the file.
76-
@if [ $(dir) != "." ]; then \
77-
echo "mkdir -p $(LC_MESSAGES)/$(dir)"; \
78-
mkdir -p $(LC_MESSAGES)/$(dir); \
79-
echo "ln -f ./$(target) $(LC_MESSAGES)/$(target)"; \
80-
ln -f ./$(target) $(LC_MESSAGES)/$(target); \
81-
fi
82-
# Build
83-
@echo "----"
72+
@mkdir -p $(LC_MESSAGES)/$(dir)
73+
@ln -f ./$(target) $(LC_MESSAGES)/$(target)
74+
8475
@. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES='$(basename $(target)).rst' html
8576

77+
8678
help:
8779
@python3 -c"$$PRINT_HELP_PYSCRIPT"<$(MAKEFILE_LIST)
8880

89-
clone:## Clone latest cpython repository to `../cpython/` if it doesn't exist
81+
.PHONY: prepare_deps
82+
prepare_deps:$(VENV)/bin/sphinx-build$(VENV)/bin/blurb upgrade_venv prepare_cpython## Prepare dependencies
83+
84+
.PHONY: prepare_cpython
85+
prepare_cpython:## Prepare CPython clone at `../cpython/`.
9086
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git$(CPYTHON_CLONE)||echo"cpython exists"
91-
cd$(CPYTHON_CLONE)&& git checkout$(BRANCH)
87+
cd$(CPYTHON_CLONE)&& git checkout$(VERSION)&& git pull origin$(VERSION)
88+
mkdir -p$(LC_MESSAGES)
9289

9390

9491
$(VENV)/bin/activate:
95-
mkdir -p$(VENV)
96-
$(PYTHON) -m venv$(VENV)
97-
92+
python3 -m venv$(VENV)
9893

9994
$(VENV)/bin/sphinx-build:$(VENV)/bin/activate
10095
.$(VENV)/bin/activate; python3 -m pip install sphinx python-docs-theme
@@ -108,7 +103,7 @@ $(VENV)/bin/blurb: $(VENV)/bin/activate
108103

109104
.PHONY: upgrade_venv
110105
upgrade_venv:$(VENV)/bin/activate## Upgrade the venv that compiles the doc
111-
.$(VENV)/bin/activate; python3 -m pip install --upgrade sphinx python-docs-theme blurb sphinx-lint
106+
@.$(VENV)/bin/activate; python3 -m pip install -q --upgrade sphinx python-docs-theme blurb sphinx-lint
112107

113108

114109
.PHONY: progress
@@ -124,10 +119,7 @@ todo: ## List remaining tasks
124119

125120

126121
.PHONY: merge
127-
merge: upgrade_venv## To merge pot from upstream
128-
ifneq "$(shell cd$(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
129-
$(error "You're merging from a different branch")
130-
endif
122+
merge: prepare_deps## To merge pot from upstream
131123
(cd$(CPYTHON_CLONE)/Doc; rm -f build/NEWS)
132124
(cd$(CPYTHON_CLONE)/Doc;$(VENV)/bin/sphinx-build -Q -b gettext -D gettext_compact=0. locales/pot/)
133125
find$(CPYTHON_CLONE)/Doc/locales/pot/ -name'*.pot'|\
@@ -146,7 +138,7 @@ endif
146138

147139
.PHONY: update_txconfig
148140
update_txconfig:
149-
curl -L https://rawgit.com/python-doc-ja/cpython-doc-catalog/catalog-$(BRANCH)/Doc/locales/.tx/config|\
141+
curl -L https://rawgit.com/python-doc-ja/cpython-doc-catalog/catalog-$(VERSION)/Doc/locales/.tx/config|\
150142
grep --invert-match'^file_filter = *'|\
151143
sed -e's/source_file = pot\/\(.*\)\.pot/trans.zh_TW = \1.po/'|\
152144
sed -n'w .tx/config'

‎README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,17 @@ the PSF for inclusion in the documentation.
142142

143143
3. 存檔以後,執行以下列指令編譯輸出完整文件,以確保你的修改沒有 reST 的語法錯誤或警告 ::
144144

145-
VERSION=3.12make all
145+
make all
146146

147147
或者只想快速檢查是否有 reST 語法錯誤 ::
148148

149-
VERSION=3.12make lint
149+
make lint
150150

151151
確保輸出中沒有任何關於正在翻譯的檔案的警告訊息。
152152

153153
在 ``make all`` 後,可以使用 ``make build`` 來只對單一 ``.po`` 檔進行編譯,可以節省較多的時間 ::
154154

155-
VERSION=3.12make build glossary.po
155+
make build glossary.po
156156

157157
如果你還沒有執行 `維護、預覽`_ 的 clone CPython 的動作,此指令會自動幫你 clone CPython,\
158158
並且會使用 Sphinx 幫你檢查 reST 語法錯誤,我們盡量保持沒有 warning \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp