Skip to content

Disable literal block when linting #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,30 @@ cd "$rootdir"
mkdir -p logs
touch logs/sphinxlint.txt

cd cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES
sphinx-lint | tee $(realpath "$rootdir/logs/sphinxlint.txt")
cd $OLDPWD
cd cpython/Doc

# Remove empty file
# 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 ${PYDOC_LANGUAGE} > /dev/null

cd locale/${PYDOC_LANGUAGE}/LC_MESSAGES
sphinx-lint 2> $(realpath "$rootdir/logs/sphinxlint.txt")

# Undo changes to undo literal blocks disabling
git checkout .

cd "$rootdir"

# Check of logfile is empty
if [ ! -s logs/sphinxlint.txt ]; then
# OK, it is empty. Remove it.
rm logs/sphinxlint.txt
else
# print contents and exit with error status (to trigger notification in CI)
cat logs/sphinxlint.txt
exit 1
fi