From 4fd1c23ae3b631188aebbf73251d04c18c42f274 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Tue, 26 Apr 2011 16:28:22 -0300 Subject: Update inheritance diagram sphinx extension. Better handling missing classes. Reviewer: Renato Araujo Reviewer: Marcelo Lira --- doc/inheritance_diagram.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/inheritance_diagram.py b/doc/inheritance_diagram.py index 7b13094e8..616b47057 100644 --- a/doc/inheritance_diagram.py +++ b/doc/inheritance_diagram.py @@ -100,15 +100,22 @@ class InheritanceGraph(object): __import__(fullname) todoc = sys.modules[fullname] except ImportError: + # else it is a class, then import the module + if not path: + if currmodule: + # try the current module + path = currmodule + else: + raise InheritanceException( + 'Could not import class %r specified for ' + 'inheritance diagram' % base) try: - __import__(currmodule) - todoc = sys.modules[currmodule] - for attr in name.split('.'): - todoc = getattr(todoc, attr) + __import__(path) + todoc = getattr(sys.modules[path], base) except (ImportError, AttributeError): raise InheritanceException( 'Could not import class or module %r specified for ' - 'inheritance diagram' % (currmodule + '.' + name)) + 'inheritance diagram' % (path + '.' + base)) # If a class, just return it if inspect.isclass(todoc): -- cgit v1.2.3