From 274fc20fbb9a1a533c5d31ef31233a4fa5652044 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Fri, 11 Oct 2024 22:02:25 -0300 Subject: [PATCH 1/3] Disable literal block translation when linting --- scripts/lint.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 2ac6674fe..b91f695d2 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -18,9 +18,23 @@ cd "$rootdir" mkdir -p logs touch logs/sphinxlint.txt -cd cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES +cd cpython/Doc + +# Disable literal blocks and update PO +sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py +# TODO: use `make -C .. gettext` when there are only Python >= 3.12 +opts='-E -b gettext -q -D gettext_compact=0 -d build/.doctrees . build/gettext' +make build ALLSPHINXOPTS="$opts" +# Update translation files with latest POT +sphinx-intl update -d locale -p build/gettext -l pt_BR > /dev/null + +cd locale/${PYDOC_LANGUAGE}/LC_MESSAGES sphinx-lint | tee $(realpath "$rootdir/logs/sphinxlint.txt") -cd $OLDPWD + +# Undo changes that disabled literal blocks +git checkout *.po + +cd "$rootdir" # Remove empty file if [ ! -s logs/sphinxlint.txt ]; then From 1d2a32c8bc9e6a1d209ef64db7c434468a0dfd8d Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 17 Oct 2024 09:25:45 -0300 Subject: [PATCH 2/3] Fix exit status for lint.sh --- scripts/lint.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index b91f695d2..98d037792 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -26,17 +26,21 @@ sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py opts='-E -b gettext -q -D gettext_compact=0 -d build/.doctrees . build/gettext' make build ALLSPHINXOPTS="$opts" # Update translation files with latest POT -sphinx-intl update -d locale -p build/gettext -l pt_BR > /dev/null +sphinx-intl update -d locale -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null cd locale/${PYDOC_LANGUAGE}/LC_MESSAGES -sphinx-lint | tee $(realpath "$rootdir/logs/sphinxlint.txt") +sphinx-lint 2> >(tee -a $(realpath "$rootdir/logs/sphinxlint.txt") >&2) -# Undo changes that disabled literal blocks -git checkout *.po +# Undo changes to undo literal blocks disabling +git checkout . cd "$rootdir" -# Remove empty file +# Check of logfile is empty if [ ! -s logs/sphinxlint.txt ]; then + # OK, it is empty. Remove it. rm logs/sphinxlint.txt +else + # has contents, exit with error status (to trigger notification in CI) + exit 1 fi From c57578085e8cd8489546d95ef4283f1c026eb9ac Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 17 Oct 2024 09:59:10 -0300 Subject: [PATCH 3/3] Simplify error output redirect in lint.sh To avoid "Syntax error: redirection unexpected" --- scripts/lint.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 98d037792..27ddfdbb9 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -29,7 +29,7 @@ make build ALLSPHINXOPTS="$opts" sphinx-intl update -d locale -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null cd locale/${PYDOC_LANGUAGE}/LC_MESSAGES -sphinx-lint 2> >(tee -a $(realpath "$rootdir/logs/sphinxlint.txt") >&2) +sphinx-lint 2> $(realpath "$rootdir/logs/sphinxlint.txt") # Undo changes to undo literal blocks disabling git checkout . @@ -41,6 +41,7 @@ if [ ! -s logs/sphinxlint.txt ]; then # OK, it is empty. Remove it. rm logs/sphinxlint.txt else - # has contents, exit with error status (to trigger notification in CI) + # print contents and exit with error status (to trigger notification in CI) + cat logs/sphinxlint.txt exit 1 fi