8000 gh-101100: Docs: Check Sphinx warnings and fail if improved by hugovk · Pull Request #106460 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-101100: Docs: Check Sphinx warnings and fail if improved #106460

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 8 commits into from
Jul 22, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Group warnings under filename
  • Loading branch information
hugovk committed Jul 6, 2023
commit 3522e2c2aa04e23fc37e868750ba05706f485f31
8 changes: 5 additions & 3 deletions Doc/tools/check-warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"venv",
}

PATTERN = re.compile(r"(?P<file>[^:]+):(?P<line>\d+): WARNING: (?P<msg>.+)")


def check_and_annotate(warnings: list[str], files_to_check: str) -> None:
"""
Expand All @@ -39,11 +41,10 @@ def check_and_annotate(warnings: list[str], files_to_check: str) -> None:
see:
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
"""
pattern = re.compile(r"(?P<file>[^:]+):(?P<line>\d+): WARNING: (?P<msg>.+)")
files_to_check = next(csv.reader([files_to_check]))
for warning in warnings:
if any(filename in warning for filename in files_to_check):
if match := pattern.fullmatch(warning):
if match := PATTERN.fullmatch(warning):
print("::warning file={file},line={line}::{msg}".format_map(match))


Expand All @@ -67,7 +68,8 @@ def fail_if_regression(
print(filename)
for warning in warnings:
if filename in warning:
print(warning)
if match := PATTERN.fullmatch(warning):
print(" {line}: {msg}".format_map(match))
return -1
return 0

Expand Down
0