The `alt` text of inheritance diagrams is now much cleaner:

it's not the graphviz code but a description "Inheritance diagram of ...".
This commit is contained in:
Georg Brandl
2010-01-03 11:47:46 +01:00
parent 0b70a32efe
commit b9294de041
3 changed files with 11 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
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

View File

@@ -128,7 +128,8 @@ def render_dot(self, code, options, format, prefix='graphviz'):
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:
@@ -145,16 +146,17 @@ def render_dot_html(self, node, code, options, prefix='graphviz', imgcls=None):
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

View File

@@ -301,7 +301,7 @@ class InheritanceDiagram(Directive):
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]
@@ -329,7 +329,8 @@ def html_visit_inheritance_diagram(self, 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