Kaydet (Commit) 28a4f0f9 authored tarafından Brett Cannon's avatar Brett Cannon

Have pydoc try handling an object as "other" if the object does not act the way

it expects based on what inspect classifies it as.

Closes bug #729103 .
üst 10147f7d
...@@ -275,9 +275,16 @@ class Doc: ...@@ -275,9 +275,16 @@ class Doc:
def document(self, object, name=None, *args): def document(self, object, name=None, *args):
"""Generate documentation for an object.""" """Generate documentation for an object."""
args = (object, name) + args args = (object, name) + args
if inspect.ismodule(object): return self.docmodule(*args) # 'try' clause is to attempt to handle the possibility that inspect
if inspect.isclass(object): return self.docclass(*args) # identifies something in a way that pydoc itself has issues handling;
if inspect.isroutine(object): return self.docroutine(*args) # think 'super' and how it is a descriptor (which raises the exception
# by lacking a __name__ attribute) and an instance.
try:
if inspect.ismodule(object): return self.docmodule(*args)
if inspect.isclass(object): return self.docclass(*args)
if inspect.isroutine(object): return self.docroutine(*args)
except AttributeError:
pass
return self.docother(*args) return self.docother(*args)
def fail(self, object, name=None, *args): def fail(self, object, name=None, *args):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment