Commits

Georg Brandl committed 43d46b2 Merge

merge with stable

  • Participants
  • Parent commits 8478b81, ee2d5b1

Comments (0)

Files changed (8)

 
 * #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!
 ======================================================================

doc/markup/misc.rst

    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
 
 

sphinx/__init__.py

File contents unchanged.

sphinx/builders/html.py

         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

sphinx/builders/qthelp.py

 
 from sphinx import addnodes
 from sphinx.builders.html import StandaloneHTMLBuilder
+from sphinx.util import force_decode
 from sphinx.util.pycompat import htmlescape
 
 
         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 = []
         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):

sphinx/environment.py

 
     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 '#'
         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):

sphinx/ext/autodoc.py

             # 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:

sphinx/writers/html.py

             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: