Commits

Georg Brandl committed 1798609 Merge

merge with 0.6

Comments (0)

Files changed (25)

 Release 0.6.3 (in development)
 ==============================
 
+* #220: Fix CSS so that displaymath really is centered.
+
+* #222: Allow the "Footnotes" header to be translated.
+
+* #225: Don't add whitespace in generated HTML after inline tags.
+
+* #227: Make ``literalinclude`` work when the document's path
+  name contains non-ASCII characters.
+
+* #229: Fix autodoc failures with members that raise errors
+  on ``getattr()``.
+
+* #205: When copying files, don't copy full stat info, only
+  modification times.
+
+* #232: Support non-ASCII metadata in Qt help builder.
+
 * Properly format bullet lists nested in definition lists for LaTeX.
 
 * Section titles are now allowed inside ``only`` directives.

doc/markup/para.rst

 
    .. note::
 
-      If the *title* of the rubric is "Footnotes", this rubric is ignored by
-      the LaTeX writer, since it is assumed to only contain footnote
-      definitions and therefore would create an empty heading.
+      If the *title* of the rubric is "Footnotes" (or the selected language's
+      equivalent), this rubric is ignored by the LaTeX writer, since it is
+      assumed to only contain footnote definitions and therefore would create an
+      empty heading.
 
 
 .. directive:: centered

sphinx/builders/qthelp.py

 import os
 import re
 import cgi
+import codecs
 from os import path
 
 from docutils import nodes
 # It contains references to compressed help files which should be
 # included in the collection.
 # It may contain various other information for customizing Qt Assistant.
-collection_template = '''\
+collection_template = u'''\
 <?xml version="1.0" encoding="utf-8" ?>
 <QHelpCollectionProject version="1.0">
     <docFiles>
 # It contains the table of contents, indices and references to the
 # actual documentation files (*.html).
 # In addition it defines a unique namespace for the documentation.
-project_template = '''\
+project_template = u'''\
 <?xml version="1.0" encoding="UTF-8"?>
 <QtHelpProject version="1.0">
     <namespace>%(outname)s.org.%(outname)s.%(nversion)s</namespace>
 
     def build_qhcp(self, outdir, outname):
         self.info('writing collection project file...')
-        f = open(path.join(outdir, outname+'.qhcp'), 'w')
+        f = codecs.open(path.join(outdir, outname+'.qhcp'), 'w', 'utf-8')
         try:
             f.write(collection_template % {'outname': outname})
         finally:
         projectfiles = '\n'.join(projectfiles)
 
         # write the project file
-        f = open(path.join(outdir, outname+'.qhp'), 'w')
+        f = codecs.open(path.join(outdir, outname+'.qhp'), 'w', 'utf-8')
         try:
             nversion = self.config.version.replace('.', '_')
             nversion = nversion.replace(' ', '_')

sphinx/directives/code.py

         else:
             docdir = path.dirname(env.doc2path(env.docname, base=None))
             rel_fn = path.normpath(path.join(docdir, filename))
-        fn = path.join(env.srcdir, rel_fn)
+        try:
+            fn = path.join(env.srcdir, rel_fn)
+        except UnicodeDecodeError:
+            # the source directory is a bytestring with non-ASCII characters;
+            # let's try to encode the rel_fn in the file system encoding
+            rel_fn = rel_fn.encode(sys.getfilesystemencoding())
+            fn = path.join(env.srcdir, rel_fn)
 
         if 'pyobject' in self.options and 'lines' in self.options:
             return [document.reporter.warning(

sphinx/ext/autodoc.py

 from sphinx.pycode import ModuleAnalyzer, PycodeError
 from sphinx.application import ExtensionError
 from sphinx.util.compat import Directive
+from sphinx.util.inspect import isdescriptor, safe_getmembers, safe_getattr
 from sphinx.util.docstrings import prepare_docstring
 
 
     return process
 
 
-def safe_getattr(obj, name, *defargs):
-    try:
-        return getattr(obj, name, *defargs)
-    except Exception:
-        # this is a catch-all for all the weird things that some modules do
-        # with attribute access
-        if defargs:
-            return defargs[0]
-        raise AttributeError
-
-
-def isdescriptor(x):
-    """Check if the object is some kind of descriptor."""
-    for item in '__get__', '__set__', '__delete__':
-        if hasattr(safe_getattr(x, item, None), '__call__'):
-            return True
-    return False
-
-
 class Documenter(object):
     """
     A Documenter knows how to autodocument a single object type.  When
                                         % (mname, self.fullname))
             return False, ret
         elif self.options.inherited_members:
-            # getmembers() uses dir() which pulls in members from all
+            # safe_getmembers() uses dir() which pulls in members from all
             # base classes
-            return False, inspect.getmembers(self.object)
+            return False, safe_getmembers(self.object)
         else:
             # __dict__ contains only the members directly defined in
             # the class (but get them via getattr anyway, to e.g. get
             if not hasattr(self.object, '__all__'):
                 # for implicit module members, check __module__ to avoid
                 # documenting imported objects
-                return True, inspect.getmembers(self.object)
+                return True, safe_getmembers(self.object)
             else:
                 memberlist = self.object.__all__
         else:

sphinx/locale/cs/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/de/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/es/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/fi/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/fr/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/it/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/ja/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/nl/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/pl/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/ru/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/sl/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/sphinx.pot

File contents unchanged.

sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po

File contents unchanged.

sphinx/themes/basic/static/basic.css

     vertical-align: middle;
 }
 
-div.math p {
+div.body div.math p {
     text-align: center;
 }
 

sphinx/util/__init__.py

 import os
 import re
 import sys
+import stat
 import time
 import types
 import shutil
     os.rename(source, dest)
 
 
+def copytimes(source, dest):
+    """Copy a file's modification times."""
+    st = os.stat(source)
+    mode = stat.S_IMODE(st.st_mode)
+    if hasattr(os, 'utime'):
+        os.utime(dest, (st.st_atime, st.st_mtime))
+
+
 def copyfile(source, dest):
     """Copy a file and its modification times, if possible."""
     shutil.copyfile(source, dest)
-    try: shutil.copystat(source, dest)
-    except shutil.Error: pass
+    try:
+        # don't do full copystat because the source may be read-only
+        copytimes(source, dest)
+    except shutil.Error:
+        pass
 
 
 def copy_static_entry(source, target, builder, context={}):

sphinx/util/inspect.py

+# -*- coding: utf-8 -*-
+"""
+    sphinx.util.inspect
+    ~~~~~~~~~~~~~~~~~~~
+
+    Helpers for inspecting Python modules.
+
+    :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
+    :license: BSD, see LICENSE for details.
+"""
+
+def isdescriptor(x):
+    """Check if the object is some kind of descriptor."""
+    for item in '__get__', '__set__', '__delete__':
+        if hasattr(safe_getattr(x, item, None), '__call__'):
+            return True
+    return False
+
+
+def safe_getattr(obj, name, *defargs):
+    """A getattr() that turns all exceptions into AttributeErrors."""
+    try:
+        return getattr(obj, name, *defargs)
+    except Exception:
+        # this is a catch-all for all the weird things that some modules do
+        # with attribute access
+        if defargs:
+            return defargs[0]
+        raise AttributeError(name)
+
+
+def safe_getmembers(object, predicate=None):
+    """A version of inspect.getmembers() that uses safe_getattr()."""
+    results = []
+    for key in dir(object):
+        try:
+            value = safe_getattr(object, key, None)
+        except AttributeError:
+            continue
+        if not predicate or predicate(value):
+            results.append((key, value))
+    results.sort()
+    return results

sphinx/writers/html.py

         self.body.append('<span class="optional">]</span>')
 
     def visit_desc_annotation(self, node):
-        self.body.append(self.starttag(node, 'em', CLASS='property'))
+        self.body.append(self.starttag(node, 'em', '', CLASS='property'))
     def depart_desc_annotation(self, node):
         self.body.append('</em>')
 
         attrs = {}
         if node.hasattr('explanation'):
             attrs['title'] = node['explanation']
-        self.body.append(self.starttag(node, 'abbr', **attrs))
+        self.body.append(self.starttag(node, 'abbr', '', **attrs))
     def depart_abbreviation(self, node):
         self.body.append('</abbr>')
 

sphinx/writers/latex.py

         self.body.append("\n\n")
 
     def visit_rubric(self, node):
-        if len(node.children) == 1 and node.children[0].astext() == 'Footnotes':
+        if len(node.children) == 1 and node.children[0].astext() in \
+               ('Footnotes', _('Footnotes')):
             raise nodes.SkipNode
         self.body.append('\\paragraph{')
         self.context.append('}\n')