@@ -295,7 +295,7 @@ def pandas_validate(func_name: str):
295
295
return result
296
296
297
297
298
- def validate_all (prefix , ignore_deprecated = False ):
298
+ def validate_all (prefix , ignore_deprecated = False , ignore_functions = None ):
299
299
"""
300
300
Execute the validation of all docstrings, and return a dict with the
301
301
results.
@@ -307,6 +307,8 @@ def validate_all(prefix, ignore_deprecated=False):
307
307
validated. If None, all docstrings will be validated.
308
308
ignore_deprecated: bool, default False
309
309
If True, deprecated objects are ignored when validating docstrings.
310
+ ignore_functions: list of str or None, default None
311
+ If not None, contains a list of function to ignore
310
312
311
313
Returns
312
314
-------
@@ -317,6 +319,11 @@ def validate_all(prefix, ignore_deprecated=False):
317
319
result = {}
318
320
seen = {}
319
321
322
+ if ignore_functions is None :
323
+ ignore_functions = {}
324
+ else :
325
+ ignore_functions = set (ignore_functions )
326
+
320
327
base_path = pathlib .Path (__file__ ).parent .parent
321
328
api_doc_fnames = pathlib .Path (base_path , "doc" , "source" , "reference" )
322
329
api_items = []
@@ -325,7 +332,9 @@ def validate_all(prefix, ignore_deprecated=False):
325
332
api_items += list (get_api_items (f ))
326
333
327
334
for func_name , _ , section , subsection in api_items :
328
- if prefix and not func_name .startswith (prefix ):
335
+ if (
336
+ prefix and not func_name .startswith (prefix )
337
+ ) or func_name in ignore_functions :
329
338
continue
330
339
doc_info = pandas_validate (func_name )
331
340
if ignore_deprecated and doc_info ["deprecated" ]:
@@ -353,11 +362,12 @@ def print_validate_all_results(
353
362
errors : list [str ] | None ,
354
363
output_format : str ,
355
364
ignore_deprecated : bool ,
365
+ ignore_functions : list [str ] | None ,
356
366
):
357
367
if output_format not in ("default" , "json" , "actions" ):
358
368
raise ValueError (f'Unknown output_format "{ output_format } "' )
359
369
360
- result = validate_all (prefix , ignore_deprecated )
370
+ result = validate_all (prefix , ignore_deprecated , ignore_functions )
361
371
362
372
if output_format == "json" :
363
373
sys .stdout .write (json .dumps (result ))
@@ -408,13 +418,17 @@ def header(title, width=80, char="#"):
408
418
sys .stderr .write (result ["examples_errs" ])
409
419
410
420
411
- def main (func_name , prefix , errors , output_format , ignore_deprecated ):
421
+ def main (func_name , prefix , errors , output_format , ignore_deprecated , ignore_functions ):
412
422
"""
413
423
Main entry point. Call the validation for one or for all docstrings.
414
424
"""
415
425
if func_name is None :
416
426
return print_validate_all_results (
417
- prefix , errors , output_format , ignore_deprecated
427
+ prefix ,
428
+ errors ,
429
+ output_format ,
430
+ ignore_deprecated ,
431
+ ignore_functions ,
418
432
)
419
433
else :
420
434
print_validate_one_results (func_name )
@@ -464,6 +478,13 @@ def main(func_name, prefix, errors, output_format, ignore_deprecated):
464
478
"deprecated objects are ignored when validating "
465
479
"all docstrings" ,
466
480
)
481
+ argparser .add_argument (
482
+ "--ignore_functions" ,
483
+ default = None ,
484
+ help = "function or method to not validate "
485
+ "(e.g. Pandas.DataFrame.head). "
486
+ "Inverse of the `function` argument." ,
487
+ )
467
488
468
489
args = argparser .parse_args ()
469
490
sys .exit (
@@ -473,5 +494,6 @@ def main(func_name, prefix, errors, output_format, ignore_deprecated):
473
494
args .errors .split ("," ) if args .errors else None ,
474
495
args .format ,
475
496
args .ignore_deprecated ,
497
+ args .ignore_functions .split ("," ) if args .ignore_functions else None ,
476
498
)
477
499
)
0 commit comments