summaryrefslogtreecommitdiff
path: root/sphinx/ext
diff options
context:
space:
mode:
authorJon Olav Vik <jonovik@gmail.com>2011-09-26 08:07:53 +0200
committerJon Olav Vik <jonovik@gmail.com>2011-09-26 08:07:53 +0200
commite518b1fe07d3a84c0ed8d17d7df61c4f3668f206 (patch)
treedda0204efe94e00f80fd607e3afda9e2cb065e8e /sphinx/ext
parent4753865249e11c866eaf2f85a252e02281dd2870 (diff)
downloadsphinx-e518b1fe07d3a84c0ed8d17d7df61c4f3668f206.tar.gz
Inheritance diagram: Make tooltip from first line of docstring
Diffstat (limited to 'sphinx/ext')
-rw-r--r--sphinx/ext/inheritance_diagram.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py
index a2490486..58f140bd 100644
--- a/sphinx/ext/inheritance_diagram.py
+++ b/sphinx/ext/inheritance_diagram.py
@@ -246,6 +246,14 @@ class InheritanceGraph(object):
url = urls.get(fullname)
if url is not None:
this_node_attrs['URL'] = '"%s"' % url
+ # Use first line of docstring as tooltip
+ modulename, classname = fullname.rsplit(".", 1)
+ module = __import__(modulename, fromlist=[classname])
+ cls = module.__dict__[classname]
+ doc = inspect.getdoc(cls)
+ if doc:
+ this_node_attrs['tooltip'] = '"%s"' % doc.split("\n")[0]
+
res.append(' "%s" [%s];\n' %
(name, self._format_node_attrs(this_node_attrs)))