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
137f37b2fc
17
CHANGES
17
CHANGES
@ -38,6 +38,23 @@ Release 1.0 (in development)
|
||||
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.
|
||||
|
@ -88,9 +88,10 @@ units as well as normal text:
|
||||
|
||||
.. 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
|
||||
|
@ -12,6 +12,7 @@
|
||||
import os
|
||||
import re
|
||||
import cgi
|
||||
import codecs
|
||||
from os import path
|
||||
|
||||
from docutils import nodes
|
||||
@ -28,7 +29,7 @@ _idpattern = re.compile(
|
||||
# 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>
|
||||
@ -50,7 +51,7 @@ collection_template = '''\
|
||||
# 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>
|
||||
@ -109,7 +110,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
|
||||
|
||||
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:
|
||||
@ -161,7 +162,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
|
||||
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(' ', '_')
|
||||
|
@ -103,7 +103,13 @@ class LiteralInclude(Directive):
|
||||
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(
|
||||
|
@ -25,6 +25,7 @@ from sphinx.util import rpartition, nested_parse_with_titles, force_decode
|
||||
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
|
||||
|
||||
|
||||
@ -194,25 +195,6 @@ def between(marker, what=None, keepempty=False):
|
||||
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
|
||||
@ -492,9 +474,9 @@ class Documenter(object):
|
||||
% (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
|
||||
@ -734,7 +716,7 @@ class ModuleDocumenter(Documenter):
|
||||
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:
|
||||
|
@ -378,7 +378,7 @@ img.math {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.math p {
|
||||
div.body div.math p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import stat
|
||||
import time
|
||||
import types
|
||||
import shutil
|
||||
@ -399,11 +400,22 @@ def movefile(source, dest):
|
||||
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={}):
|
||||
|
43
sphinx/util/inspect.py
Normal file
43
sphinx/util/inspect.py
Normal file
@ -0,0 +1,43 @@
|
||||
# -*- 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
|
@ -123,7 +123,7 @@ class HTMLTranslator(BaseTranslator):
|
||||
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>')
|
||||
|
||||
@ -457,7 +457,7 @@ class HTMLTranslator(BaseTranslator):
|
||||
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>')
|
||||
|
||||
|
@ -574,7 +574,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
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')
|
||||
|
Loading…
Reference in New Issue
Block a user