mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
merge with 0.6
This commit is contained in:
commit
7e53338d9a
4
CHANGES
4
CHANGES
@ -52,6 +52,10 @@ Release 1.0 (in development)
|
||||
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.
|
||||
|
||||
|
@ -438,6 +438,10 @@ class StandaloneHTMLBuilder(Builder):
|
||||
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()
|
||||
|
@ -35,7 +35,7 @@ from docutils.transforms.parts import ContentsFilter
|
||||
|
||||
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
|
||||
|
||||
@ -821,11 +821,11 @@ class BuildEnvironment:
|
||||
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
|
||||
@ -1075,7 +1075,7 @@ class BuildEnvironment:
|
||||
# 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='',
|
||||
@ -1225,7 +1225,7 @@ class BuildEnvironment:
|
||||
# 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(
|
||||
|
@ -161,7 +161,8 @@ def get_svg_tag(svgref, svgfile, imgcls=None):
|
||||
(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'):
|
||||
@ -176,6 +177,8 @@ def render_dot_html(self, node, code, options, prefix='graphviz', imgcls=None):
|
||||
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)
|
||||
@ -189,13 +192,12 @@ def render_dot_html(self, node, code, options, prefix='graphviz', imgcls=None):
|
||||
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')
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -443,6 +443,13 @@ def copy_static_entry(source, target, builder, context={}):
|
||||
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."""
|
||||
@ -451,6 +458,7 @@ def split_explicit_title(text):
|
||||
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!
|
||||
|
Loading…
Reference in New Issue
Block a user