MCPcopy
hub / github.com/numpy/numpy / check_rest

Function check_rest

tools/refguide_check.py:476–543  ·  view source on GitHub ↗

Check reStructuredText formatting of docstrings Parameters ---------- module : ModuleType names : set Returns ------- result : list List of [(module_name, success_flag, output),...]

(module, names, dots=True)

Source from the content-addressed store, hash-verified

474
475
476def check_rest(module, names, dots=True):
477 """
478 Check reStructuredText formatting of docstrings
479
480 Parameters
481 ----------
482 module : ModuleType
483
484 names : set
485
486 Returns
487 -------
488 result : list
489 List of [(module_name, success_flag, output),...]
490 """
491
492 skip_types = (dict, str, float, int)
493
494 results = []
495
496 if module.__name__[6:] not in OTHER_MODULE_DOCS:
497 results += [(module.__name__,) +
498 validate_rst_syntax(inspect.getdoc(module),
499 module.__name__, dots=dots)]
500
501 for name in names:
502 full_name = module.__name__ + '.' + name
503 obj = getattr(module, name, None)
504
505 if obj is None:
506 results.append((full_name, False, f"{full_name} has no docstring"))
507 continue
508 elif isinstance(obj, skip_types):
509 continue
510
511 if inspect.ismodule(obj):
512 text = inspect.getdoc(obj)
513 else:
514 try:
515 text = str(get_doc_object(obj))
516 except Exception:
517 import traceback
518 results.append((full_name, False,
519 "Error in docstring format!\n" +
520 traceback.format_exc()))
521 continue
522
523 m = re.search("([\x00-\x09\x0b-\x1f])", text)
524 if m:
525 msg = (f"Docstring contains a non-printable character {m.group(1)!r}! "
526 "Maybe forgot r\"\"\"?")
527 results.append((full_name, False, msg))
528 continue
529
530 try:
531 src_file = short_path(inspect.getsourcefile(obj))
532 except TypeError:
533 src_file = None

Callers 1

mainFunction · 0.85

Calls 2

validate_rst_syntaxFunction · 0.85
short_pathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…