Skip to content

Commit 0cc6277

Browse files
committed
Add docstring name to validation warnings.
1 parent 1b6b424 commit 0cc6277

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

numpydoc/numpydoc.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,15 @@ def mangle_docstrings(app, what, name, obj, options, lines):
180180
# selected via config are reported. It would be more efficient to
181181
# only run the selected checks.
182182
errors = validate(doc)["errors"]
183-
for err in errors:
184-
# err[0] = error code
185-
if err[0] in app.config.numpydoc_validation_checks:
186-
logger.warning(err)
183+
if {err[0] for err in errors} & app.config.numpydoc_validation_checks:
184+
msg = (
185+
f"[numpydoc] Validation warnings while processing "
186+
f"docstring for {name!r}:\n"
187+
)
188+
for err in errors:
189+
if err[0] in app.config.numpydoc_validation_checks:
190+
msg += f" {err[0]}: {err[1]}\n"
191+
logger.warning(msg)
187192

188193

189194
if (app.config.numpydoc_edit_link and hasattr(obj, '__name__') and

0 commit comments

Comments
 (0)