Update inheritance diagram sphinx extension.
Better handling missing classes. Reviewer: Renato Araujo <renato.filho@openbossa.org> Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
a68d4b04f3
commit
b32b614d1b
1 changed files with 12 additions and 5 deletions
|
|
@ -100,15 +100,22 @@ class InheritanceGraph(object):
|
||||||
__import__(fullname)
|
__import__(fullname)
|
||||||
todoc = sys.modules[fullname]
|
todoc = sys.modules[fullname]
|
||||||
except ImportError:
|
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:
|
try:
|
||||||
__import__(currmodule)
|
__import__(path)
|
||||||
todoc = sys.modules[currmodule]
|
todoc = getattr(sys.modules[path], base)
|
||||||
for attr in name.split('.'):
|
|
||||||
todoc = getattr(todoc, attr)
|
|
||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
raise InheritanceException(
|
raise InheritanceException(
|
||||||
'Could not import class or module %r specified for '
|
'Could not import class or module %r specified for '
|
||||||
'inheritance diagram' % (currmodule + '.' + name))
|
'inheritance diagram' % (path + '.' + base))
|
||||||
|
|
||||||
# If a class, just return it
|
# If a class, just return it
|
||||||
if inspect.isclass(todoc):
|
if inspect.isclass(todoc):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue