Skip to content

Commit 54e8795

Browse files
authored
lint: Disable literal-block only on 3.12 or newer (#241)
* lint: Disable literal-block only on 3.12 or newer * lint: disable unnecessary-parentheses check on 3.11 or older * Drop sphinx-lint==0.9.1 from requirements.txt * lint: silence output of make gettext
1 parent 9e898a9 commit 54e8795

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

requirements.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
potodo==0.21.3
22
powrap==1.0.1
33
sphinx-intl==2.2.0
4-
# avoid unnecessary parentheses search in old Python Docs
5-
sphinx-lint==1.0.0; python_version >= "3.12"
6-
sphinx-lint==0.9.1; python_version < "3.12"
4+
sphinx-lint==1.0.0

scripts/lint.sh

+11-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ touch logs/sphinxlint.txt
2020

2121
cd cpython/Doc
2222

23-
# Disable literal blocks and update PO
24-
sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py
25-
# TODO: use `make -C .. gettext` when there are only Python >= 3.12
26-
opts='-E -b gettext -q -D gettext_compact=0 -d build/.doctrees . build/gettext'
27-
make build ALLSPHINXOPTS="$opts"
28-
# Update translation files with latest POT
29-
sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null
23+
# If version is 3.12 or newer, then disable literal-block, generate POT and
24+
# update translations with fresh POT files. If version 3.11 or older,
25+
# disable new 'unnecessary-parentheses' check, not fixed before these versions.
26+
minor_version=$(git branch --show-current | sed 's|^3\.||')
27+
if [ $minor_version -ge 12 ]; then
28+
sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py
29+
make gettext SPHINXOPTS='-q'
30+
sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null
31+
else
32+
alias sphinx-lint='sphinx-lint --disable unnecessary-parentheses'
33+
fi
3034

3135
cd locales/${PYDOC_LANGUAGE}/LC_MESSAGES
3236
set +e

0 commit comments

Comments
 (0)