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

fix(make): always link the build target#913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
cschan1828 merged 4 commits intopython:3.12frommattwang44:fix/issue-912
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
# Here is what you can do:
#
# - make all # Automatically build an html local version
# - make build # To build a single .po file
# - make build<po-file> # To build a single .po file
# - make todo # To list remaining tasks
# - make merge # To merge pot from upstream
# - make fuzzy # To find fuzzy strings
Expand DownExpand Up@@ -37,25 +37,23 @@ print('\n'.join(output))
endef
export PRINT_HELP_PYSCRIPT # End of python section

CPYTHON_CLONE := ../cpython/
CPYTHON_CLONE := ../cpython
VERSION := $(or $(VERSION), 3.12)
SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py
LANGUAGE := zh_TW
LC_MESSAGES := $(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/LC_MESSAGES
VENV := ~/.venvs/python-docs-i18n/
PYTHON := $(shell which python3)
MODE := autobuild-dev-html
BRANCH := $(or $(VERSION), $(shell git describe --contains --all HEAD))
JOBS := 4

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

.PHONY: build
build:$(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone## Automatically build an html local version
build:prepare_deps## Automatically build an html local version for a single file
@$(eval target=$(filter-out $@,$(MAKECMDGOALS)))
@if [ -z $(target) ]; then \
echo "\x1B[1;31m""Please provide a file argument.""\x1B[m"; \
Expand All@@ -69,32 +67,29 @@ build: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build a
echo "\x1B[1;31m""ERROR: $(target) not exist.""\x1B[m"; \
exit 1; \
fi
@mkdir -p $(LC_MESSAGES)

@$(eval dir=`echo $(target) | xargs -n1 dirname`) ## Get dir
# If the build target is in under directory
# We should make direcotry in $(LC_MESSAGES) and link the file.
@if [ $(dir) != "." ]; then \
echo "mkdir -p $(LC_MESSAGES)/$(dir)"; \
mkdir -p $(LC_MESSAGES)/$(dir); \
echo "ln -f ./$(target) $(LC_MESSAGES)/$(target)"; \
ln -f ./$(target) $(LC_MESSAGES)/$(target); \
fi
# Build
@echo "----"
@mkdir -p $(LC_MESSAGES)/$(dir)
@ln -f ./$(target) $(LC_MESSAGES)/$(target)

@. $(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


help:
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clone: ## Clone latest cpython repository to `../cpython/` if it doesn't exist
.PHONY: prepare_deps
prepare_deps: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb upgrade_venv prepare_cpython ## Prepare dependencies

.PHONY: prepare_cpython
prepare_cpython: ## Prepare CPython clone at `../cpython/`.
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git $(CPYTHON_CLONE) || echo "cpython exists"
cd $(CPYTHON_CLONE) && git checkout $(BRANCH)
cd $(CPYTHON_CLONE) && git checkout $(VERSION) && git pull origin $(VERSION)
mkdir -p $(LC_MESSAGES)


$(VENV)/bin/activate:
mkdir -p $(VENV)
$(PYTHON) -m venv $(VENV)

python3 -m venv $(VENV)

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

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


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


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

.PHONY: update_txconfig
update_txconfig:
curl -L https://rawgit.com/python-doc-ja/cpython-doc-catalog/catalog-$(BRANCH)/Doc/locales/.tx/config |\
curl -L https://rawgit.com/python-doc-ja/cpython-doc-catalog/catalog-$(VERSION)/Doc/locales/.tx/config |\
grep --invert-match '^file_filter = *' |\
sed -e 's/source_file = pot\/\(.*\)\.pot/trans.zh_TW = \1.po/' |\
sed -n 'w .tx/config'
Expand Down
6 changes: 3 additions & 3 deletionsREADME.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,17 +142,17 @@ the PSF for inclusion in the documentation.

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

VERSION=3.12make all
make all

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

VERSION=3.12make lint
make lint

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

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

VERSION=3.12make build glossary.po
make build glossary.po

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

[8]ページ先頭

©2009-2025 Movatter.jp