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

Commit912fe24

Browse files
authored
Merge pull request#26 from gilgamezh/update_makefile
2 parents711f899 +9ed64a6 commit912fe24

File tree

5 files changed

+293
-83
lines changed

5 files changed

+293
-83
lines changed

‎.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,50 @@
11
*.mo
22
/_build/
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
venv
13+
.Python
14+
env/
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
.mypy_cache/
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.coverage
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
48+
# Ides
49+
.vscode/
50+
.idea/

‎.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ install:
1111
script:
1212
-powrap --check --quiet **/*.po
1313
-pospell -p dict -l es_ES **/*.po
14-
-makeCPYTHON_CLONE=/tmp/cpython/ COMMIT=15e7d2432294ec46f1ad84ce958fdeb9d4ca78b1
14+
-makebuild

‎CONTRIBUTING.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Guía para contribuir en la documentación utilizando Github
2+
===========================================================
3+
4+
Crea un fork y clona el repositorio
5+
-----------------------------------
6+
7+
https://help.github.com/en/github/getting-started-with-github/fork-a-repo
8+
9+
Luego de tener un fork clonalo en tu maquina
10+
11+
..code-block::bash
12+
13+
# Git clone your github fork using ssh (replace raulcd):
14+
# Clona el repositorio en tu maquina ejecutando
15+
git@github.com:<TU_USUARIO>/python-docs-es.git
16+
17+
# Ingresá al nuevo directorio con el repo
18+
cd python-docs-es/
19+
20+
# Agregá el repositorio original como upstream.
21+
git remote add upstream https://github.com/raulcd/python-docs-es.git
22+
23+
24+
Crear un build local
25+
--------------------
26+
27+
Hay un script para automatizar estos pasos el mismo va a:
28+
29+
- Crear un virtualenv dentro del directorio del repositorio e instalar en el mismo las librearias necesarias
30+
- Clonar el repositorio oficial de cpython para construir ("biuldear") la documentación.
31+
32+
..code-block::bash
33+
34+
make build
35+
36+
# luego para poder ver la documentación ejecuta el siguiente comando y podes luego ir a http://localhost:8000 para ver la documentación
37+
# recién construida.
38+
make serve

‎Makefile

Lines changed: 201 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,204 @@
1-
# Makefile for es Python Documentation
21
#
3-
# Here is what you can do:
2+
# Makefile for Spanish Python Documentation
3+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44
#
5-
# - make # Automatically build an html local version
6-
# - make todo # To list remaining tasks
7-
# - make merge # To merge pot from upstream
8-
# - make fuzzy # To find fuzzy strings
9-
# - make progress # To compute current progression
10-
# - make upgrade_venv # To upgrade the venv that compiles the doc
5+
# based on: https://github.com/python/python-docs-pt-br/blob/3.8/Makefile
116
#
12-
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
13-
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
14-
# real work to the Python Doc Makefile.
15-
16-
CPYTHON_CLONE := ../cpython/
17-
SPHINX_CONF :=$(CPYTHON_CLONE)/Doc/conf.py
18-
LANGUAGE := es
19-
VENV := ~/.venvs/python-docs-i18n/
20-
PYTHON :=$(shell which python3)
21-
MODE := html
22-
BRANCH = 3.7
23-
COMMIT =
24-
JOBS = auto
25-
26-
27-
.PHONY: all
28-
all:$(SPHINX_CONF)$(VENV)/bin/activate
29-
ifneq "$(shell cd$(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
30-
$(warning "Your ../cpython checkout may be on the wrong branch, got $(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD) expected $(BRANCH)")
31-
endif
32-
mkdir -p $(CPYTHON_CLONE)/locales/$(LANGUAGE)/
33-
ln -nfs $(shell $(PYTHON) -c 'import os; print(os.path.realpath("."))') $(CPYTHON_CLONE)/locales/$(LANGUAGE)/LC_MESSAGES
34-
$(MAKE) -C $(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) SPHINXOPTS='-qW -j$(JOBS) -D locale_dirs=../locales -D language=$(LANGUAGE) -D gettext_compact=0 -D latex_engine=xelatex -D latex_elements.inputenc= -D latex_elements.fontenc=' $(MODE)
35-
36-
37-
$(SPHINX_CONF):
38-
git clone --depth 1 --branch$(BRANCH) https://github.com/python/cpython.git$(CPYTHON_CLONE)
39-
[-n"$(COMMIT)" ]&& (i=1;while!$$(git -C$(CPYTHON_CLONE) checkout$(COMMIT));do i=$$((i*2)); git -C$(CPYTHON_CLONE) fetch --depth$$i; done)||true
40-
41-
42-
.PHONY: upgrade_venv
43-
upgrade_venv:
44-
$(MAKE) -C$(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) venv
45-
46-
47-
$(VENV)/bin/activate:
48-
$(MAKE) -C$(CPYTHON_CLONE)/Doc/ VENVDIR=$(VENV) PYTHON=$(PYTHON) venv
49-
50-
51-
.PHONY: progress
52-
progress:
53-
@python3 -c'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))'\
54-
$(shell msgcat*.po*/*.po | msgattrib --translated | grep -c '^msgid')\
55-
$(shell msgcat*.po*/*.po | grep -c '^msgid')
56-
57-
58-
.PHONY: merge
59-
merge: upgrade_venv
60-
ifneq "$(shell cd$(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" "$(BRANCH)"
61-
$(error "You're merging from a different branch:" "$(shell cd $(CPYTHON_CLONE) 2>/dev/null && git describe --contains --all HEAD)" vs "$(BRANCH)")
62-
endif
63-
(cd $(CPYTHON_CLONE)/Doc; rm -f build/NEWS)
64-
(cd $(CPYTHON_CLONE); $(VENV)/bin/sphinx-build -Q -b gettext -D gettext_compact=0 Doc pot/)
65-
find $(CPYTHON_CLONE)/pot/ -name '*.pot' |\
66-
while read -r POT;\
67-
do\
68-
PO="./$$(echo "$$POT" | sed "s#$(CPYTHON_CLONE)/pot/##; s#\.pot\$$#.po#")";\
69-
mkdir -p "$$(dirname "$$PO")";\
70-
if [ -f "$$PO" ];\
71-
then\
72-
case "$$POT" in\
73-
*whatsnew*) msgmerge --backup=off --force-po --no-fuzzy-matching -U "$$PO" "$$POT" ;;\
74-
*) msgmerge --backup=off --force-po -U "$$PO" "$$POT" ;;\
75-
esac\
76-
else\
77-
msgcat -o "$$PO" "$$POT";\
78-
fi\
79-
done
80-
81-
82-
.PHONY: fuzzy
83-
fuzzy:
84-
forfilein*.po*/*.po;doecho$$(msgattrib --only-fuzzy --no-obsolete"$$file"| grep -c'#, fuzzy')$$file;done| grep -v ^0| sort -gr
7+
8+
# Configuration
9+
10+
CPYTHON_PATH := cpython#Current commit for this upstream repo is setted by the submodule
11+
BRANCH := 3.7
12+
LANGUAGE_TEAM := python-docs-es
13+
LANGUAGE := es
14+
15+
# Internal variables
16+
VENV :=$(shell realpath ./venv)
17+
PYTHON :=$(shell which python3)
18+
WORKDIRS :=$(VENV)/workdirs
19+
CPYTHON_WORKDIR :=$(WORKDIRS)/cpython
20+
LOCALE_DIR :=$(WORKDIRS)/locale
21+
JOBS := auto
22+
SPHINXERRORHANDLING := "-W"
23+
TRANSIFEX_PROJECT := python-newest
24+
POSPELL_TMP_DIR := .pospell
25+
26+
27+
.PHONY: help
28+
help:
29+
@echo"Please use 'make <target>' where <target> is one of:"
30+
@echo" build Build an local version in html, with warnings as errors"
31+
@echo" push Update translations and Transifex config in the repository"
32+
@echo" pull Download translations from Transifex; calls 'venv'"
33+
@echo" tx-config Recreate an up-to-date project .tx/config; calls 'pot'"
34+
@echo" pot Create/Update POT files from source files"
35+
@echo" serve Serve a built documentation on http://localhost:8000"
36+
@echo" spell Check spelling, storing output in$(POSPELL_TMP_DIR)"
37+
@echo""
38+
39+
40+
# build: build the documentation using the translation files currently available
41+
# at the moment. For most up-to-date docs, run "tx-config" and "pull"
42+
# before this. If passing SPHINXERRORHANDLING='', warnings will not be
43+
# treated as errors, which is good to skip simple Sphinx syntax mistakes.
44+
.PHONY: build
45+
build: setup
46+
$(MAKE) -C$(CPYTHON_WORKDIR)/Doc/\
47+
VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv\
48+
PYTHON=$(PYTHON)\
49+
SPHINXERRORHANDLING=$(SPHINXERRORHANDLING)\
50+
SPHINXOPTS='-q --keep-going -j$(JOBS) \
51+
-D locale_dirs=$(LOCALE_DIR)\
52+
-D language=$(LANGUAGE)\
53+
-D gettext_compact=0\
54+
-D latex_engine=xelatex\
55+
-D latex_elements.inputenc=\
56+
-D latex_elements.fontenc=' \
57+
html;
58+
59+
@echo"Success! Open file://$(CPYTHON_WORKDIR)/Doc/build/html/index.html,"\
60+
"or run 'make serve' to see them in http://localhost:8000";
61+
62+
63+
# push: push new translation files and Transifex config files to repository,
64+
# if any. Do nothing if there is no file changes. If GITHUB_TOKEN is set,
65+
# then assumes we are in GitHub Actions, requiring different push args
66+
.PHONY: push
67+
push:
68+
if! git status -s| egrep'\.po|\.tx/config';then \
69+
echo"Nothing to commit";\
70+
exit 0;\
71+
else\
72+
git add*.po**/*.po .tx/config;\
73+
git commit -m'Update translations from Transifex';\
74+
if [$(GITHUB_TOKEN)!="" ];then \
75+
header="$(echo -n token:"$(GITHUB_TOKEN)"| base64)";\
76+
git -c http.extraheader="AUTHORIZATION: basic$(header)" push;\
77+
else\
78+
git push;\
79+
fi;\
80+
fi
81+
82+
83+
# pull: Download translations files from Transifex, and apply line wrapping.
84+
# For downloading new translation files, first run "tx-config" target
85+
# to update the translation file mapping.
86+
.PHONY: pull
87+
pull: venv
88+
$(VENV)/bin/tx pull --force --language=$(LANGUAGE) --parallel
89+
$(VENV)/bin/powrap --quiet*.po**/*.po
90+
91+
92+
# tx-config: After running "pot", create a new Transifex config file by
93+
# reading pot files generated, then tweak this config file to
94+
# LANGUAGE.
95+
.PHONY: tx-config
96+
tx-config: pot
97+
cd$(CPYTHON_WORKDIR)/Doc/locales;\
98+
rm -rf .tx;\
99+
$(VENV)/bin/sphinx-intl create-txconfig;\
100+
$(VENV)/bin/sphinx-intl update-txconfig-resources\
101+
--transifex-project-name=$(TRANSIFEX_PROJECT)\
102+
--locale-dir.\
103+
--pot-dir pot;
104+
105+
cd$(OLDPWD)
106+
mv$(CPYTHON_WORKDIR)/Doc/locales/.tx/config .tx/config
107+
108+
sed -i .tx/config\
109+
-e'/^source_file/d'\
110+
-e's|<lang>/LC_MESSAGES/||'\
111+
-e"s|^file_filter|trans.$(LANGUAGE)|"
112+
113+
114+
# pot: After running "setup" target, run a cpython Makefile's target
115+
# to generate .pot files under $(CPYTHON_WORKDIR)/Doc/locales/pot
116+
.PHONY: pot
117+
pot: setup
118+
$(MAKE) -C$(CPYTHON_WORKDIR)/Doc/\
119+
VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv\
120+
PYTHON=$(PYTHON)\
121+
ALLSPHINXOPTS='-E -b gettext \
122+
-D gettext_compact=0\
123+
-d build/.doctrees.\
124+
locales/pot' \
125+
build
126+
127+
128+
# setup: After running "venv" target, prepare that virtual environment with
129+
# a local clone of cpython repository and the translation files.
130+
# If the directories exists, only update the cpython repository and
131+
# the translation files copy which could have new/updated files.
132+
.PHONY: setup
133+
setup: venv
134+
# Setup the main clone
135+
git submodule sync
136+
git submodule update --init --force$(CPYTHON_PATH)
137+
# Setup the current work directory
138+
if! [-d$(CPYTHON_WORKDIR) ];then \
139+
rm -fr$(WORKDIRS);\
140+
mkdir -p$(WORKDIRS);\
141+
git clone$(CPYTHON_PATH)$(CPYTHON_WORKDIR);\
142+
$(MAKE) -C$(CPYTHON_WORKDIR)/Doc\
143+
VENVDIR=$(CPYTHON_WORKDIR)/Doc/venv\
144+
PYTHON=$(PYTHON) venv;\
145+
fi
146+
147+
# Setup translation files
148+
if! [-d$(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/ ];then \
149+
mkdir -p$(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/;\
150+
fi;\
151+
cp --parents*.po**/*.po$(LOCALE_DIR)/$(LANGUAGE)/LC_MESSAGES/\
152+
153+
154+
# venv: create a virtual environment which will be used by almost every
155+
# other target of this script
156+
.PHONY: venv
157+
venv:
158+
if [!-d$(VENV) ];then \
159+
$(PYTHON) -m venv --prompt$(LANGUAGE_TEAM)$(VENV);\
160+
fi
161+
162+
$(VENV)/bin/python -m pip install -q -r requirements.txt2>$(VENV)/pip-install.log
163+
164+
if grep -q'pip install --upgrade pip'$(VENV)/pip-install.log;then \
165+
$(VENV)/bin/pip install -q --upgrade pip;\
166+
fi
167+
168+
169+
# serve: serve the documentation in a simple local web server, using cpython
170+
# Makefile's "serve" target. Run "build" before using this target.
171+
.PHONY: serve
172+
serve:
173+
$(MAKE) -C$(CPYTHON_WORKDIR)/Doc serve
174+
175+
176+
# list files for spellchecking
177+
SRCS :=$(wildcard*.po**/*.po)
178+
DESTS =$(addprefix$(POSPELL_TMP_DIR)/out/,$(patsubst%.po,%.txt,$(SRCS)))
179+
180+
181+
# spell: run spell checking tool in all po files listed in SRCS variable,
182+
# storing the output in text files DESTS for proofreading. The
183+
# DESTS target run the spellchecking, while the typos.txt target
184+
# gather all reported issues in one file, sorted without redundancy
185+
.PHONY: spell
186+
spell: venv$(DESTS)$(POSPELL_TMP_DIR)/typos.txt
187+
188+
$(POSPELL_TMP_DIR)/out/%.txt:%.po dict
189+
@echo"Checking $< ..."
190+
@mkdir -p$(@D)
191+
@$(VENV)/bin/pospell -l$(LANGUAGE) -p dict$<>$@||true
192+
193+
$(POSPELL_TMP_DIR)/typos.txt:
194+
@echo"Gathering all typos in$(POSPELL_TMP_DIR)/typos.txt ..."
195+
@cut -d: -f3-$(DESTS)| sort -u>$@
196+
197+
198+
# clean: remove all .mo files and the venv directory that may exist and
199+
# could have been created by the actions in other targets of this script
200+
.PHONY: clean
201+
clean:
202+
rm -fr$(VENV)
203+
rm -rf$(POSPELL_TMP_DIR)
204+
find -name'*.mo' -delete

‎requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
Sphinx==2.2.0
2-
setuptools
32
blurb
3+
pospell
4+
powrap
45
python-docs-theme
6+
setuptools
7+
sphinx-intl
8+
transifex-client

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp