MCPcopy Index your code
hub / github.com/RustPython/RustPython / getdoc

Function getdoc

Lib/inspect.py:771–788  ·  view source on GitHub ↗

Get the documentation string for an object. All tabs are expanded to spaces. To clean up docstrings that are indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.

(object)

Source from the content-addressed store, hash-verified

769 return None
770
771def getdoc(object):
772 """Get the documentation string for an object.
773
774 All tabs are expanded to spaces. To clean up docstrings that are
775 indented to line up with blocks of code, any whitespace than can be
776 uniformly removed from the second line onwards is removed."""
777 try:
778 doc = object.__doc__
779 except AttributeError:
780 return None
781 if doc is None:
782 try:
783 doc = _finddoc(object)
784 except (AttributeError, TypeError):
785 return None
786 if not isinstance(doc, str):
787 return None
788 return cleandoc(doc)
789
790def cleandoc(doc):
791 """Clean up indentation from docstrings.

Callers

nothing calls this directly

Calls 3

isinstanceFunction · 0.85
cleandocFunction · 0.85
_finddocFunction · 0.70

Tested by

no test coverage detected