mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
bpo-40257: Improve help for the typing module (GH-19546)
* Show docstring for special forms. * Show docstring for special generic aliases. * Show documentation for __origin__ for generic aliases.
This commit is contained in:
parent
c606624af8
commit
7e64414f57
5 changed files with 24 additions and 4 deletions
|
@ -1445,7 +1445,7 @@ location listed above.
|
|||
if not doc:
|
||||
doc = getdoc(object)
|
||||
if doc:
|
||||
line += '\n' + self.indent(str(doc))
|
||||
line += '\n' + self.indent(str(doc)) + '\n'
|
||||
return line
|
||||
|
||||
class _PlainTextDoc(TextDoc):
|
||||
|
@ -1672,8 +1672,11 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
|
|||
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)
|
||||
desc += ' object'
|
||||
if hasattr(object, '__origin__'):
|
||||
object = object.__origin__
|
||||
else:
|
||||
object = type(object)
|
||||
desc += ' object'
|
||||
return title % desc + '\n\n' + renderer.document(object, name)
|
||||
|
||||
def doc(thing, title='Python Library Documentation: %s', forceload=0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue