Skip to content

Commit 41b4c27

Browse files
authored
Carefully parse warning messages when building documentation (#8693)
1 parent 2c92a29 commit 41b4c27

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/build

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,19 @@ def parse_sphinx_warnings(warning_text: str) -> List[DocBuildError]:
272272
continue
273273
warning_parts = sphinx_warning.split(":", 2)
274274
if len(warning_parts) == 3:
275-
sphinx_build_errors.append(
276-
DocBuildError(
277-
file_path=warning_parts[0], line_no=int(warning_parts[1]), message=warning_parts[2]
275+
try:
276+
sphinx_build_errors.append(
277+
DocBuildError(
278+
file_path=warning_parts[0], line_no=int(warning_parts[1]), message=warning_parts[2]
279+
)
280+
)
281+
except Exception: # pylint: disable=broad-except
282+
# If an exception occurred while parsing the warning message, display the raw warning message.
283+
sphinx_build_errors.append(
284+
DocBuildError(
285+
file_path=None, line_no=None, message=sphinx_warning
286+
)
278287
)
279-
)
280288
else:
281289
sphinx_build_errors.append(DocBuildError(file_path=None, line_no=None, message=sphinx_warning))
282290
return sphinx_build_errors

0 commit comments

Comments
 (0)