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)
| 1783 | return title % desc + '\n\n' + renderer.document(object, name) |
| 1784 | |
| 1785 | def doc(thing, title='Python Library Documentation: %s', forceload=0, |
| 1786 | output=None, is_cli=False): |
| 1787 | """Display text documentation, given an object or a path to an object.""" |
| 1788 | if output is None: |
| 1789 | try: |
| 1790 | if isinstance(thing, str): |
| 1791 | what = thing |
| 1792 | else: |
| 1793 | what = getattr(thing, '__qualname__', None) |
| 1794 | if not isinstance(what, str): |
| 1795 | what = getattr(thing, '__name__', None) |
| 1796 | if not isinstance(what, str): |
| 1797 | what = type(thing).__name__ + ' object' |
| 1798 | pager(render_doc(thing, title, forceload), f'Help on {what!s}') |
| 1799 | except ImportError as exc: |
| 1800 | if is_cli: |
| 1801 | raise |
| 1802 | print(exc) |
| 1803 | else: |
| 1804 | try: |
| 1805 | s = render_doc(thing, title, forceload, plaintext) |
| 1806 | except ImportError as exc: |
| 1807 | s = str(exc) |
| 1808 | output.write(s) |
| 1809 | |
| 1810 | def writedoc(thing, forceload=0): |
| 1811 | """Write HTML documentation to a file in the current directory.""" |
no test coverage detected