Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e6dac74

Browse files
committed
fix: several fixes to scripts
- 'serve' target is not available in Python Docs, so use the htmlview commands as alternative to check docs - Pull translations into cpython sub-directory and then copy to langauge repository, as the previous patch in .tx/config no longer works with the new Transifex CLI tool - Use realpath in update.sh ROOTDIR to make it easier to go back to the repository root directory
1 parent e3307b1 commit e6dac74

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

scripts/build.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@ LANGUAGE=${1:-pt_BR}
99

1010
ROOTDIR="$(dirname $0)/.."
1111

12-
cd ${ROOTDIR}
12+
cd "${ROOTDIR}"
1313

14-
test -f cpython/Doc/conf.py || ( echo Unable to find proper CPython Doc folder; exit 1; )
14+
if ! test -f cpython/Doc/conf.py; then
15+
echo Unable to find proper CPython Doc folder
16+
exit 1
17+
fi
1518

16-
pofiles=$(find . -maxdepth 2 -name '*.po' | sort -u)
19+
pofiles=$(find . -maxdepth 2 -name '*.po' | sort -u | sed -i 's|\./||')
1720

1821
for po in ${pofiles}; do
1922
install -Dm644 ${po} "cpython/Doc/locales/${LANGUAGE}/LC_MESSAGES/${po}"
2023
done
2124

22-
sphinx-build -b html -d build/doctrees -q --keep-going -jauto -D locale_dirs=locales -D language=pt_BR -D gettext_compact=0 -D latex_engine=xelatex -D latex_elements.inputenc= -D latex_elements.fontenc= -W cpython/Doc cpython/Doc/build/html
25+
sphinx-build -b html -d build/doctrees -n -a --keep-going -jauto -D locale_dirs=locales -D language=pt_BR -D gettext_compact=0 -D latex_engine=xelatex -D latex_elements.inputenc= -D latex_elements.fontenc= -W cpython/Doc cpython/Doc/build/html
2326

2427
if [ -z "$GITHUB_ACTIONS" ]; then
25-
echo "See file:/$(realpath ${ROOTDIR})/cpython/Doc/build/html/index.html"
26-
echo "or serve it in http://localhost:8080 by running:"
27-
echo "python3 cpython/Tools/scripts/serve.py cpython/Doc/build/html"
28+
echo 'See the built documentation by running the following command:'
29+
echo 'python3 -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('cpython/Doc/build/html/index.html'))""'
2830
fi

scripts/update.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ set -e
77
# Allow language being passed as 1st argument, defaults to pt_BR
88
LANGUAGE=${1:-pt_BR}
99

10-
ROOTDIR=$(dirname $0)/..
10+
ROOTDIR=$(realpath "$(dirname $0)/..")
1111

1212
cd ${ROOTDIR}
1313

14-
test -f cpython/Doc/conf.py || ( echo Unable to find proper CPython Doc folder; exit 1; )
14+
if ! test -f cpython/Doc/conf.py; then
15+
echo Unable to find proper CPython Doc folder
16+
exit 1
17+
fi
1518

1619
# Create POT Files
1720
cd cpython/Doc
@@ -20,15 +23,13 @@ sphinx-build -E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot
2023
# Update CPython's .tx/config
2124
cd locales
2225
sphinx-intl create-txconfig
23-
sphinx-intl update-txconfig-resources -p pot -d . --transifex-project-name python-newest
24-
25-
# Update the translation project's .tx/config
26-
cd ../../.. # back to $ROOTDIR
27-
mkdir -p .tx
28-
sed cpython/Doc/locales/.tx/config \
29-
-e '/^source_file/d' \
30-
-e 's|<lang>/LC_MESSAGES/||' \
31-
-e "s|^file_filter|trans.${LANGUAGE}|" \
32-
> .tx/config
33-
34-
tx pull --languages ${LANGUAGE} --translations --use-git-timestamps --parallel
26+
sphinx-intl update-txconfig-resources -p pot -d . --transifex-organization-name python-doc --transifex-project-name python-newest
27+
28+
# Pull translations into cpython/Doc/locales/LANGUAGE/LC_MESSAGES/
29+
tx pull -l ${LANGUAGE} -t --use-git-timestamps -f
30+
31+
# Finally, move downloaded translation files to the language's repository
32+
cd "${LANGUAGE}/LC_MESSAGES/"
33+
for po in $(find . -type f -name '*.po' | sort | sed 's|^\./||'); do
34+
install -Dm644 ${po} "${ROOTDIR}/${po}"
35+
done

0 commit comments

Comments
 (0)