From 4d23e9fec5130ac3c3f674d0463dd183e4b4f32f Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 4 Nov 2024 16:45:00 -0300 Subject: [PATCH 1/4] lint: Disable literal-block only on 3.12 or newer --- scripts/lint.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 927f8e5a5..51db26e1e 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -20,13 +20,14 @@ touch logs/sphinxlint.txt 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 -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null +# If version is 3.12 or newer, then disable literal-block, generate POT and +# update translations with fresh POT files. +minor_version=$(git branch --show-current | sed 's|^3\.||') +if [ $minor_version -ge 12 ]; then + sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py + make gettext + sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null +fi cd locales/${PYDOC_LANGUAGE}/LC_MESSAGES set +e From 41df1173c689b8e0b54832aa84f78526bef9b0aa Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 4 Nov 2024 16:59:27 -0300 Subject: [PATCH 2/4] lint: disable unnecessary-parentheses check on 3.11 or older --- scripts/lint.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 51db26e1e..4ffc45b49 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -21,12 +21,15 @@ touch logs/sphinxlint.txt cd cpython/Doc # If version is 3.12 or newer, then disable literal-block, generate POT and -# update translations with fresh POT files. +# update translations with fresh POT files. If version 3.11 or older, +# disable new 'unnecessary-parentheses' check, not fix before these versions. minor_version=$(git branch --show-current | sed 's|^3\.||') if [ $minor_version -ge 12 ]; then sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py make gettext sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null +else + alias sphinx-lint='sphinx-lint --disable unnecessary-parentheses' fi cd locales/${PYDOC_LANGUAGE}/LC_MESSAGES From 001f0303a9e683be85815e2e3a457b8e2923009f Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 4 Nov 2024 17:00:10 -0300 Subject: [PATCH 3/4] Drop sphinx-lint==0.9.1 from requirements.txt --- requirements.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index d8c4e144f..b96c08251 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,4 @@ potodo==0.21.3 powrap==1.0.1 sphinx-intl==2.2.0 -# avoid unnecessary parentheses search in old Python Docs -sphinx-lint==1.0.0; python_version >= "3.12" -sphinx-lint==0.9.1; python_version < "3.12" +sphinx-lint==1.0.0 From 2c0f1323c4b99c2136b7bd7d51b9d6453ad18a63 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 4 Nov 2024 17:49:03 -0300 Subject: [PATCH 4/4] lint: silence output of make gettext --- scripts/lint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 4ffc45b49..3748d01a3 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -22,11 +22,11 @@ cd cpython/Doc # If version is 3.12 or newer, then disable literal-block, generate POT and # update translations with fresh POT files. If version 3.11 or older, -# disable new 'unnecessary-parentheses' check, not fix before these versions. +# disable new 'unnecessary-parentheses' check, not fixed before these versions. minor_version=$(git branch --show-current | sed 's|^3\.||') if [ $minor_version -ge 12 ]; then sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py - make gettext + make gettext SPHINXOPTS='-q' sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null else alias sphinx-lint='sphinx-lint --disable unnecessary-parentheses'