MCPcopy Index your code
hub / github.com/python/cpython / getdoc

Function getdoc

Lib/inspect.py:792–812  ·  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, *, fallback_to_class_doc=True, inherit_class_doc=True)

Source from the content-addressed store, hash-verified

790 return None
791
792def getdoc(object, *, fallback_to_class_doc=True, inherit_class_doc=True):
793 """Get the documentation string for an object.
794
795 All tabs are expanded to spaces. To clean up docstrings that are
796 indented to line up with blocks of code, any whitespace than can be
797 uniformly removed from the second line onwards is removed."""
798 if fallback_to_class_doc:
799 try:
800 doc = object.__doc__
801 except AttributeError:
802 return None
803 else:
804 doc = _getowndoc(object)
805 if doc is None:
806 try:
807 doc = _finddoc(object, search_in_class=inherit_class_doc)
808 except (AttributeError, TypeError):
809 return None
810 if not isinstance(doc, str):
811 return None
812 return cleandoc(doc)
813
814def cleandoc(doc):
815 """Clean up indentation from docstrings.

Callers

nothing calls this directly

Calls 3

_getowndocFunction · 0.85
_finddocFunction · 0.85
cleandocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…