Commits

Georg Brandl committed 7e80409 Merge

merge with 0.6

  • Participants
  • Parent commits 8da66eb, cd67597

Comments (0)

Files changed (6)

 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
   the ``doctest`` extension.
 

File sphinx/builders/html.py

                 else:
                     stripped = ''
 
+                # we stripped the whole module name
+                if not mn:
+                    continue
+
                 if fl != mn[0].lower() and mn[0] != '_':
                     # heading
                     letter = mn[0].upper()

File sphinx/environment.py

 
 from sphinx import addnodes
 from sphinx.util import movefile, get_matching_docs, SEP, ustrftime, \
-     docname_join, FilenameUniqDict, url_re
+     docname_join, FilenameUniqDict, url_re, clean_astext
 from sphinx.errors import SphinxError
 from sphinx.directives import additional_xref_types
 
                           node.line)
             self.anonlabels[name] = docname, labelid
             if node.tagname == 'section':
-                sectname = node[0].astext() # node[0] == title node
+                sectname = clean_astext(node[0]) # node[0] == title node
             elif node.tagname == 'figure':
                 for n in node:
                     if n.tagname == 'caption':
-                        sectname = n.astext()
+                        sectname = clean_astext(n)
                         break
                 else:
                     continue
                         # toctree originates
                         ref = toctreenode['parent']
                         if not title:
-                            title = self.titles[ref].astext()
+                            title = clean_astext(self.titles[ref])
                         reference = nodes.reference('', '',
                                                     refuri=ref,
                                                     anchorname='',
                             # reference with explicit title
                             caption = node.astext()
                         else:
-                            caption = self.titles[docname].astext()
+                            caption = clean_astext(self.titles[docname])
                         innernode = nodes.emphasis(caption, caption)
                         newnode = nodes.reference('', '')
                         newnode['refuri'] = builder.get_relative_uri(

File sphinx/ext/graphviz.py

            (svgref, imgcss, style)
 
 
-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):
     format = self.builder.config.graphviz_output_format
     try:
         if format not in ('png', 'svg'):
     if fname is None:
         self.body.append(self.encode(code))
     else:
+        if alt is None:
+            alt = self.encode(code).strip()
         if format == 'svg':
             svgtag = get_svg_tag(fname, outfn, imgcls)
             self.body.append(svgtag)
             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')

File 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
 
 

File sphinx/util/__init__.py

         shutil.copytree(source, target)
 
 
+def clean_astext(node):
+    """Like node.astext(), but ignore images."""
+    node = node.deepcopy()
+    for img in node.traverse(docutils.nodes.image):
+        img['alt'] = ''
+    return node.astext()
+
 
 def split_explicit_title(text):
     """Split role content into title and target, if given."""
         return True, match.group(1), match.group(2)
     return False, text, text
 
+
 # monkey-patch Node.traverse to get more speed
 # traverse() is called so many times during a build that it saves
 # on average 20-25% overall build time!