forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-101100: Test docs in nit-picky mode (python#102513)
Co-authored-by: C.A.M. Gerlach <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
- Loading branch information
Showing
8 changed files
with
116 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,28 @@ jobs: | |
- name: 'Build HTML documentation' | ||
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html | ||
|
||
# Add pull request annotations for Sphinx nitpicks (missing references) | ||
- name: 'Get list of changed files' | ||
id: changed_files | ||
uses: Ana06/[email protected] | ||
- name: 'Build changed files in nit-picky mode' | ||
continue-on-error: true | ||
run: | | ||
# Mark files the pull request modified | ||
touch ${{ steps.changed_files.outputs.added_modified }} | ||
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations | ||
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 | | ||
python Doc/tools/warnings-to-gh-actions.py | ||
# Ensure some files always pass Sphinx nit-picky mode (no missing references) | ||
- name: 'Build known-good files in nit-picky mode' | ||
run: | | ||
# Mark files that must pass nit-picky | ||
touch Doc/whatsnew/3.12.rst | ||
touch Doc/library/sqlite3.rst | ||
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W) | ||
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1 | ||
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release | ||
doctest: | ||
name: 'Doctest' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Convert Sphinx warning messages to GitHub Actions. | ||
Converts lines like: | ||
.../Doc/library/cgi.rst:98: WARNING: reference target not found | ||
to: | ||
::warning file=.../Doc/library/cgi.rst,line=98::reference target not found | ||
Non-matching lines are echoed unchanged. | ||
see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message | ||
""" | ||
|
||
import re | ||
import sys | ||
|
||
pattern = re.compile(r'(?P<file>[^:]+):(?P<line>\d+): WARNING: (?P<msg>.+)') | ||
|
||
for line in sys.stdin: | ||
if match := pattern.fullmatch(line.strip()): | ||
print('::warning file={file},line={line}::{msg}'.format_map(match)) | ||
else: | ||
print(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters