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

Function doc

Lib/pydoc.py:1739–1762  ·  view source on GitHub ↗

Display text documentation, given an object or a path to an object.

(thing, title='Python Library Documentation: %s', forceload=0,
        output=None, is_cli=False)

Source from the content-addressed store, hash-verified

1737 return title % desc + '\n\n' + renderer.document(object, name)
1738
1739def doc(thing, title='Python Library Documentation: %s', forceload=0,
1740 output=None, is_cli=False):
1741 """Display text documentation, given an object or a path to an object."""
1742 if output is None:
1743 try:
1744 if isinstance(thing, str):
1745 what = thing
1746 else:
1747 what = getattr(thing, '__qualname__', None)
1748 if not isinstance(what, str):
1749 what = getattr(thing, '__name__', None)
1750 if not isinstance(what, str):
1751 what = type(thing).__name__ + ' object'
1752 pager(render_doc(thing, title, forceload), f'Help on {what!s}')
1753 except ImportError as exc:
1754 if is_cli:
1755 raise
1756 print(exc)
1757 else:
1758 try:
1759 s = render_doc(thing, title, forceload, plaintext)
1760 except ImportError as exc:
1761 s = str(exc)
1762 output.write(s)
1763
1764def writedoc(thing, forceload=0):
1765 """Write HTML documentation to a file in the current directory."""

Callers 1

helpMethod · 0.85

Calls 4

pagerFunction · 0.85
render_docFunction · 0.85
strFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected