mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #29338: The help of a builtin or extension class now includes the
constructor signature if __text_signature__ is provided for the class.
This commit is contained in:
parent
9fa4a120f0
commit
ccb5f3cee9
2 changed files with 32 additions and 3 deletions
32
Lib/pydoc.py
32
Lib/pydoc.py
|
@ -909,7 +909,21 @@ class HTMLDoc(Doc):
|
||||||
for base in bases:
|
for base in bases:
|
||||||
parents.append(self.classlink(base, object.__module__))
|
parents.append(self.classlink(base, object.__module__))
|
||||||
title = title + '(%s)' % ', '.join(parents)
|
title = title + '(%s)' % ', '.join(parents)
|
||||||
doc = self.markup(getdoc(object), self.preformat, funcs, classes, mdict)
|
|
||||||
|
decl = ''
|
||||||
|
try:
|
||||||
|
signature = inspect.signature(object)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
signature = None
|
||||||
|
if signature:
|
||||||
|
argspec = str(signature)
|
||||||
|
if argspec:
|
||||||
|
decl = name + self.escape(argspec) + '\n\n'
|
||||||
|
|
||||||
|
doc = getdoc(object)
|
||||||
|
if decl:
|
||||||
|
doc = decl + (doc or '')
|
||||||
|
doc = self.markup(doc, self.preformat, funcs, classes, mdict)
|
||||||
doc = doc and '<tt>%s<br> </tt>' % doc
|
doc = doc and '<tt>%s<br> </tt>' % doc
|
||||||
|
|
||||||
return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)
|
return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)
|
||||||
|
@ -1213,10 +1227,22 @@ location listed above.
|
||||||
parents = map(makename, bases)
|
parents = map(makename, bases)
|
||||||
title = title + '(%s)' % ', '.join(parents)
|
title = title + '(%s)' % ', '.join(parents)
|
||||||
|
|
||||||
doc = getdoc(object)
|
contents = []
|
||||||
contents = doc and [doc + '\n'] or []
|
|
||||||
push = contents.append
|
push = contents.append
|
||||||
|
|
||||||
|
try:
|
||||||
|
signature = inspect.signature(object)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
signature = None
|
||||||
|
if signature:
|
||||||
|
argspec = str(signature)
|
||||||
|
if argspec:
|
||||||
|
push(name + argspec + '\n')
|
||||||
|
|
||||||
|
doc = getdoc(object)
|
||||||
|
if doc:
|
||||||
|
push(doc + '\n')
|
||||||
|
|
||||||
# List the mro, if non-trivial.
|
# List the mro, if non-trivial.
|
||||||
mro = deque(inspect.getmro(object))
|
mro = deque(inspect.getmro(object))
|
||||||
if len(mro) > 2:
|
if len(mro) > 2:
|
||||||
|
|
|
@ -215,6 +215,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #29338: The help of a builtin or extension class now includes the
|
||||||
|
constructor signature if __text_signature__ is provided for the class.
|
||||||
|
|
||||||
- Issue #29335: Fix subprocess.Popen.wait() when the child process has
|
- Issue #29335: Fix subprocess.Popen.wait() when the child process has
|
||||||
exited to a stopped instead of terminated state (ex: when under ptrace).
|
exited to a stopped instead of terminated state (ex: when under ptrace).
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue