merge with stable

This commit is contained in:
Georg Brandl
2012-03-10 21:38:29 +01:00
7 changed files with 51 additions and 16 deletions

View File

@@ -58,6 +58,15 @@ Release 1.1.3 (in development)
* #876: Fix quickstart test under Python 3.
* #870: Fix spurious KeyErrors when removing documents.
* #892: Fix single-HTML builder misbehaving with the master document in a
subdirectory.
* #873: Fix assertion errors with empty ``only`` directives.
* #816: Fix encoding issues in the Qt help builder.
Release 1.1.2 (Nov 1, 2011) -- 1.1.1 is a silly version number anyway!
======================================================================

View File

@@ -182,6 +182,13 @@ Including content based on tags
The format of the current builder (``html``, ``latex`` or ``text``) is always
set as a tag.
.. note::
Due to docutils' specifics of parsing of directive content, you cannot put
a section with the same level as the main document heading inside an
``only`` directive. Such sections will appear to be ignored in the parsed
document.
.. versionadded:: 0.6

View File

@@ -698,9 +698,12 @@ class StandaloneHTMLBuilder(Builder):
ctx = self.globalcontext.copy()
# current_page_name is backwards compatibility
ctx['pagename'] = ctx['current_page_name'] = pagename
default_baseuri = self.get_target_uri(pagename)
# in the singlehtml builder, default_baseuri still contains an #anchor
# part, which relative_uri doesn't really like...
default_baseuri = default_baseuri.rsplit('#', 1)[0]
def pathto(otheruri, resource=False,
baseuri=self.get_target_uri(pagename)):
def pathto(otheruri, resource=False, baseuri=default_baseuri):
if resource and '://' in otheruri:
# allow non-local resources given by scheme
return otheruri

View File

@@ -19,6 +19,7 @@ from docutils import nodes
from sphinx import addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.util import force_decode
from sphinx.util.pycompat import htmlescape
@@ -130,16 +131,17 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
for indexname, indexcls, content, collapse in self.domain_indices:
item = section_template % {'title': indexcls.localname,
'ref': '%s.html' % indexname}
sections.append((' ' * 4 * 4 + item).encode('utf-8'))
sections.append(' ' * 4 * 4 + item)
# sections may be unicode strings or byte strings, we have to make sure
# they are all byte strings before joining them
# they are all unicode strings before joining them
new_sections = []
for section in sections:
if isinstance(section, unicode):
new_sections.append(section.encode('utf-8'))
if not isinstance(section, unicode):
# XXX is this really necessary?
new_sections.append(force_decode(section, None))
else:
new_sections.append(section)
sections = u'\n'.encode('utf-8').join(new_sections)
sections = u'\n'.join(new_sections)
# keywords
keywords = []
@@ -147,7 +149,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
for (key, group) in index:
for title, (refs, subitems) in group:
keywords.extend(self.build_keywords(title, refs, subitems))
keywords = '\n'.join(keywords)
keywords = u'\n'.join(keywords)
# files
if not outdir.endswith(os.sep):

View File

@@ -1164,7 +1164,12 @@ class BuildEnvironment:
def get_toc_for(self, docname, builder):
"""Return a TOC nodetree -- for use on the same page only!"""
toc = self.tocs[docname].deepcopy()
try:
toc = self.tocs[docname].deepcopy()
except KeyError:
# the document does not exist anymore: return a dummy node that
# renders to nothing
return nodes.paragraph()
self.process_only_nodes(toc, builder, docname)
for node in toc.traverse(nodes.reference):
node['refuri'] = node['anchorname'] or '#'
@@ -1507,19 +1512,21 @@ class BuildEnvironment:
self.warn_node(msg % {'target': target}, node)
def process_only_nodes(self, doctree, builder, fromdocname=None):
# A comment on the comment() nodes being inserted: replacing by [] would
# result in a "Losing ids" exception if there is a target node before
# the only node, so we make sure docutils can transfer the id to
# something, even if it's just a comment and will lose the id anyway...
for node in doctree.traverse(addnodes.only):
try:
ret = builder.tags.eval_condition(node['expr'])
except Exception, err:
self.warn_node('exception while evaluating only '
'directive expression: %s' % err, node)
node.replace_self(node.children)
node.replace_self(node.children or nodes.comment())
else:
if ret:
node.replace_self(node.children)
node.replace_self(node.children or nodes.comment())
else:
# replacing by [] would result in an "Losing ids" exception
# if there is a target node before the only node
node.replace_self(nodes.comment())
def assign_section_numbers(self):

View File

@@ -512,9 +512,13 @@ class Documenter(object):
# unbound method objects instead of function objects);
# using keys() because apparently there are objects for which
# __dict__ changes while getting attributes
obj_dict = self.get_attr(self.object, '__dict__')
members = [(mname, self.get_attr(self.object, mname, None))
for mname in obj_dict.keys()]
try:
obj_dict = self.get_attr(self.object, '__dict__')
except AttributeError:
members = []
else:
members = [(mname, self.get_attr(self.object, mname, None))
for mname in obj_dict.keys()]
membernames = set(m[0] for m in members)
# add instance attributes from the analyzer
if self.analyzer:

View File

@@ -358,6 +358,9 @@ class HTMLTranslator(BaseTranslator):
return
if node.has_key('scale'):
# Try to figure out image height and width. Docutils does that too,
# but it tries the final file name, which does not necessarily exist
# yet at the time the HTML file is written.
if Image and not (node.has_key('width')
and node.has_key('height')):
try: