summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
author?ukasz Langa <lukasz@langa.pl>2017-02-10 00:20:16 -0800
committer?ukasz Langa <lukasz@langa.pl>2017-02-10 00:20:16 -0800
commit8972587fab93cd27ac78b4eab3805f5e11164cb9 (patch)
tree3b6b18367a3054c41f3a186d60c321ef9a08ee38 /Lib/pydoc.py
parentc7a3f78cc193bfa7fc874f49ec2e0799b32da817 (diff)
parent2328d19475109a50de26fa42832a5286824b0391 (diff)
downloadcpython-8972587fab93cd27ac78b4eab3805f5e11164cb9.tar.gz
Merge 3.6 (fix #29519)
Diffstat (limited to 'Lib/pydoc.py')
-rw-r--r--Lib/pydoc.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 39db3915dc..49555405c5 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -909,7 +909,21 @@ class HTMLDoc(Doc):
for base in bases:
parents.append(self.classlink(base, object.__module__))
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 and 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>&nbsp;</tt>' % doc
return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)
@@ -1213,10 +1227,22 @@ location listed above.
parents = map(makename, bases)
title = title + '(%s)' % ', '.join(parents)
- doc = getdoc(object)
- contents = doc and [doc + '\n'] or []
+ contents = []
push = contents.append
+ try:
+ signature = inspect.signature(object)
+ except (ValueError, TypeError):
+ signature = None
+ if signature:
+ argspec = str(signature)
+ if argspec and argspec != '()':
+ push(name + argspec + '\n')
+
+ doc = getdoc(object)
+ if doc:
+ push(doc + '\n')
+
# List the mro, if non-trivial.
mro = deque(inspect.getmro(object))
if len(mro) > 2: