diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-04-15 20:00:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 20:00:20 (GMT) |
commit | fbf2786c4c89430e2067016603078cf3500cfe94 (patch) | |
tree | 151141df42e6e058127ef59eae7f95c5e4644991 /Lib/pydoc.py | |
parent | ba1bcffe5cafc1bb0ac6fdf9ecef51e75e342707 (diff) | |
download | cpython-fbf2786c4c89430e2067016603078cf3500cfe94.zip cpython-fbf2786c4c89430e2067016603078cf3500cfe94.tar.gz cpython-fbf2786c4c89430e2067016603078cf3500cfe94.tar.bz2 |
bpo-40257: Output object's own docstring in pydoc (GH-19479)
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index f172700..a89b804 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -825,11 +825,8 @@ class HTMLDoc(Doc): push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) - if callable(value) or inspect.isdatadescriptor(value): - doc = getattr(value, "__doc__", None) - else: - doc = None - if doc is None: + doc = getdoc(value) + if not doc: push('<dl><dt>%s</dl>\n' % base) else: doc = self.markup(getdoc(value), self.preformat, @@ -1309,10 +1306,7 @@ location listed above. hr.maybe() push(msg) for name, kind, homecls, value in ok: - if callable(value) or inspect.isdatadescriptor(value): - doc = getdoc(value) - else: - doc = None + doc = getdoc(value) try: obj = getattr(object, name) except AttributeError: @@ -1448,7 +1442,9 @@ location listed above. chop = maxlen - len(line) if chop < 0: repr = repr[:chop] + '...' line = (name and self.bold(name) + ' = ' or '') + repr - if doc is not None: + if not doc: + doc = getdoc(object) + if doc: line += '\n' + self.indent(str(doc)) return line @@ -1672,7 +1668,8 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0, if not (inspect.ismodule(object) or inspect.isclass(object) or inspect.isroutine(object) or - inspect.isdatadescriptor(object)): + inspect.isdatadescriptor(object) or + inspect.getdoc(object)): # If the passed object is a piece of data or an instance, # document its available methods instead of its value. object = type(object) |