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:
Serhiy Storchaka 2020-04-18 17:13:21 +03:00 committed by GitHub
parent c606624af8
commit 7e64414f57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 4 deletions

View file

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