@@ -207,7 +207,19 @@ def mangle_docstrings(app, what, name, obj, options, lines):
207
207
# TODO: Currently, all validation checks are run and only those
208
208
# selected via config are reported. It would be more efficient to
209
209
# only run the selected checks.
210
- errors = validate (doc )["errors" ]
210
+ report = validate (doc )
211
+ errors = [
212
+ err
213
+ for err in report ["errors" ]
214
+ if not (
215
+ (
216
+ overrides := app .config .numpydoc_validation_overrides .get (
217
+ err [0 ]
218
+ )
219
+ )
220
+ and re .search (overrides , report ["docstring" ])
221
+ )
222
+ ]
211
223
if {err [0 ] for err in errors } & app .config .numpydoc_validation_checks :
212
224
msg = (
213
225
f"[numpydoc] Validation warnings while processing "
@@ -285,6 +297,7 @@ def setup(app, get_doc_object_=get_doc_object):
285
297
app .add_config_value ("numpydoc_xref_ignore" , set (), True )
286
298
app .add_config_value ("numpydoc_validation_checks" , set (), True )
287
299
app .add_config_value ("numpydoc_validation_exclude" , set (), False )
300
+ app .add_config_value ("numpydoc_validation_overrides" , dict (), False )
288
301
289
302
# Extra mangling domains
290
303
app .add_domain (NumpyPythonDomain )
@@ -327,6 +340,11 @@ def update_config(app, config=None):
327
340
)
328
341
config .numpydoc_validation_excluder = exclude_expr
329
342
343
+ for check , patterns in config .numpydoc_validation_overrides .items ():
344
+ config .numpydoc_validation_overrides [check ] = re .compile (
345
+ r"|" .join (exp for exp in patterns )
346
+ )
347
+
330
348
331
349
# ------------------------------------------------------------------------------
332
350
# Docstring-mangling domains
0 commit comments