bpo-40257: Output object's own docstring in pydoc (GH-19479)

This commit is contained in:
Serhiy Storchaka 2020-04-15 23:00:20 +03:00 committed by GitHub
parent ba1bcffe5c
commit fbf2786c4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 32 deletions

View file

@ -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)