Skip to content

Commit

Permalink
lint: Disable literal-block only on 3.12 or newer (#241)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rffontenelle authored Nov 4, 2024
1 parent 9e898a9 commit 54e8795
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
18 changes: 11 additions & 7 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ 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. If version 3.11 or older,
# 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 SPHINXOPTS='-q'
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
set +e
Expand Down

0 comments on commit 54e8795

Please sign in to comment.