Generate documentation for an object.
(self, object, name=None, *args)
| 538 | % sys.version_info[:2]) |
| 539 | |
| 540 | def document(self, object, name=None, *args): |
| 541 | """Generate documentation for an object.""" |
| 542 | args = (object, name) + args |
| 543 | # 'try' clause is to attempt to handle the possibility that inspect |
| 544 | # identifies something in a way that pydoc itself has issues handling; |
| 545 | # think 'super' and how it is a descriptor (which raises the exception |
| 546 | # by lacking a __name__ attribute) and an instance. |
| 547 | try: |
| 548 | if inspect.ismodule(object): return self.docmodule(*args) |
| 549 | if inspect.isclass(object): return self.docclass(*args) |
| 550 | if inspect.isroutine(object): return self.docroutine(*args) |
| 551 | except AttributeError: |
| 552 | pass |
| 553 | if inspect.isdatadescriptor(object): return self.docdata(*args) |
| 554 | return self.docother(*args) |
| 555 | |
| 556 | def fail(self, object, name=None, *args): |
| 557 | """Raise an exception for unimplemented types.""" |