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

Upgrade Makefile, it can build single html now#643

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
josix merged 5 commits intopython:3.12fromgriiid:feature/upgrade-makefile
Apr 13, 2024

Conversation

griiid
Copy link
Contributor

@griiidgriiid commentedSep 3, 2023
edited
Loading

更新Makefile 讓他可以只轉換單一 html 檔。

指令為:VERSION=3.12 make build/<path-to-file>
例如:VERSION=3.12 make build/library/internet,就是要 buildlibrary/internet.po 的檔案

目前的版本需要大家至少有 make all 一次,之後才能夠使用make build/<path-to-file> 來轉換單一 html 檔。
如果 clone 後沒有 make all 過,會失敗;這個問題暫時還找不到解法,附上遇到的錯誤訊息如下:

Traceback (most recent call last):  File"/Users/griiid/.venvs/python-docs-i18n/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 937,in load_indexer    with open(searchindexfn, encoding='utf-8') as ft:FileNotFoundError: [Errno 2] No such file or directory:'/Users/griiid/test/cpython/Doc/build/html/searchindex.js'

需要討論:

現在暫時的語法為make build/<path-to-file>,會看起來很像是要 makebuild/ 路徑下的檔案
需要大家集思廣益,語法應該要怎麼訂比較好,謝謝。

josix and mattwang44 reacted with thumbs up emoji
We still need to make all once, and then we can build single html.
@griiidgriiidforce-pushed thefeature/upgrade-makefile branch fromb5b35e5 to2b1bdc6CompareSeptember 3, 2023 16:30
@mattwang44mattwang44 self-requested a reviewSeptember 4, 2023 16:50
Remove redundant 'exit 1'
@josix
Copy link
Collaborator

josix commentedSep 13, 2023
edited
Loading

現在暫時的語法為 make build/,會看起來很像是要 make build/ 路徑下的檔案
需要大家集思廣益,語法應該要怎麼訂比較好,謝謝。

如果是用參數帶入想要 build 的文件如何?像是make build howto/annotations.po,make build library/abc.po, etc.
實作的方式可以試試下方的範例

build:$(VENV)/bin/sphinx-build$(VENV)/bin/blurb clone## Automatically build an html local versionif [-z$(filter-out$@,$(MAKECMDGOALS)) ];then \echo"Please provide a file argument.";\exit 1;\fiif [!-f"$(filter-out$@,$(MAKECMDGOALS))" ];then \echo"File '$(filter-out$@,$(MAKECMDGOALS))' does not exist.";\exit 1;\fiif ["$(suffix$(filter-out$@,$(MAKECMDGOALS)))"!=".po" ];then \echo"Incorrect file extension. Only '.po' files are allowed.";\exit 1;\fi@mkdir -p$(LC_MESSAGES)@$(eval dir=`echo$* | 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 ./$*.po $(LC_MESSAGES)/$*.po"; \ln -f ./$*.po $(LC_MESSAGES)/$*.po; \fi# Build@echo "----"@. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES="$(basename $(filter-out $@,$(MAKECMDGOALS))).rst" html
mattwang44 reacted with heart emoji

@griiid
Copy link
ContributorAuthor

如果是用參數帶入想要 build 的文件如何?像是make build howto/annotations.po,make build library/abc.po, etc. 實作的方式可以試試下方的範例

看起來好像不錯,我來改改看

- Get argument as build target.- Check extension.- Prevent throwing error when no rule to make target.
@griiid
Copy link
ContributorAuthor

已經採用@josix 的方法並 push。
延伸問個問題:希望使用的時候要打後面的.po 呢,還是不要好呢?

A:VERSION=3.12 make build library/internet.po
B:VERSION=3.12 make build library/internet

目前是 A 方案

@mattwang44
Copy link
Collaborator

Screenshot_20230917-234051

@griiid
Copy link
ContributorAuthor

@mattwang44 你的意思是想要不管輸入 A 或 B 都可以嗎?

那我這樣子做你覺得如何 (重點是第 2 點):

  1. 如果沒有 target,回傳錯誤。
  2. 如果 target 沒有副檔名,幫他加上.po 的副檔名。
  3. 如果副檔名不是.po,回傳錯誤。
  4. 如果 target 不存在,回傳錯誤。

@mattwang44
Copy link
Collaborator

mattwang44 commentedSep 18, 2023
edited
Loading

我覺得可以,但想請你也一併考慮未來開發彈性:

  1. 未來有什麼東西是可能基於這個 PR 繼續發展的開發?我隨意舉例(未來不一定需要):
    • 想要下make build library/* 就能 build 好 library 底下的多份文件的 html
    • 想要下make build-changed 就能自動幫忙為所有被修改過的文件 build html
  2. 思考與調整目前的實作方向
    • 大概思考這些未來可能想做的東西大概會怎麼實作
    • 不要讓未來實作它們的可能性消失
    • 現在做哪些事情會讓實現他們的可能性更高?
griiid reacted with thumbs up emoji

@@ -53,6 +53,35 @@ all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an
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
@$(eval target=$(filter-out $@,$(MAKECMDGOALS)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍👍

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Somebody say this might be harmful since the variable is global, maybe I should use some special prefix on the variable name?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yeah, how about naming this with underscore prefix

@josixjosix merged commit56d000b intopython:3.12Apr 13, 2024
1 check passed
@timmy0123timmy0123 mentioned this pull requestJun 1, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mattwang44mattwang44mattwang44 left review comments

@josixjosixjosix approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@griiid@josix@mattwang44@oakmegaeddie

[8]ページ先頭

©2009-2025 Movatter.jp