Commits

Georg Brandl committed cd67597

The ``alt`` text of inheritance diagrams is now much cleaner:
it's not the graphviz code but a description "Inheritance diagram of ...".

  • Participants
  • Parent commits 583226f

Comments (0)

Files changed (3)

 Release 0.6.4 (in development)
 ==============================
 
+* The ``alt`` text of inheritance diagrams is now much cleaner.
+
 * Ignore images in section titles when generating link captions.
 
 * #310: support exception messages in the ``testoutput`` blocks of

sphinx/ext/graphviz.py

     return relfn, outfn
 
 
-def render_dot_html(self, node, code, options, prefix='graphviz', imgcls=None):
+def render_dot_html(self, node, code, options, prefix='graphviz',
+                    imgcls=None, alt=None):
     try:
         fname, outfn = render_dot(self, code, options, 'png', prefix)
     except GraphvizError, exc:
         finally:
             mapfile.close()
         imgcss = imgcls and 'class="%s"' % imgcls or ''
+        if alt is None:
+            alt = self.encode(code).strip()
         if len(imgmap) == 2:
             # nothing in image map (the lines are <map> and </map>)
             self.body.append('<img src="%s" alt="%s" %s/>\n' %
-                             (fname, self.encode(code).strip(), imgcss))
+                             (fname, alt, imgcss))
         else:
             # has a map: get the name of the map and connect the parts
             mapname = mapname_re.match(imgmap[0]).group(1)
             self.body.append('<img src="%s" alt="%s" usemap="#%s" %s/>\n' %
-                             (fname, self.encode(code).strip(),
-                              mapname, imgcss))
+                             (fname, alt, mapname, imgcss))
             self.body.extend(imgmap)
     self.body.append('</p>\n')
     raise nodes.SkipNode

sphinx/ext/inheritance_diagram.py

         node['graph'] = graph
         # Store the original content for use as a hash
         node['parts'] = self.options.get('parts', 0)
-        node['content'] = ' '.join(class_names)
+        node['content'] = ', '.join(class_names)
         return [node]
 
 
             urls[child['reftitle']] = '#' + child.get('refid')
 
     dotcode = graph.generate_dot(name, parts, urls, env=self.builder.env)
-    render_dot_html(self, node, dotcode, [], 'inheritance', 'inheritance')
+    render_dot_html(self, node, dotcode, [], 'inheritance', 'inheritance',
+                    alt='Inheritance diagram of ' + node['content'])
     raise nodes.SkipNode