merge with 0.6

This commit is contained in:
Georg Brandl 2009-05-17 12:59:16 +02:00
commit 3ac7ff8ec6
6 changed files with 54 additions and 10 deletions

View File

@ -17,6 +17,14 @@ Release 1.0 (in development)
Release 0.6.2 (in development)
==============================
* #172: The ``obj`` role now links to modules as promised.
* #19: Tables now can have a "longtable" class, in order to get
correctly broken into pages in LaTeX output.
* Look for Sphinx message catalogs in the system default path before
trying ``sphinx/locale``.
* Fix the search for methods via "classname.methodname".
* #155: Fix Python 2.4 compatibility: exceptions are old-style

View File

@ -34,6 +34,9 @@ are already present, work fine and can be seen "in action" in the Python docs:
* Code handling: automatic highlighting using the Pygments highlighter
* Various extensions are available, e.g. for automatic testing of snippets
and inclusion of appropriately formatted docstrings.
A development egg can be found `here
<http://bitbucket.org/birkenfeld/sphinx/get/tip.gz#egg=Sphinx-dev>`_.
'''
requires = ['Pygments>=0.8', 'Jinja2>=2.1', 'docutils>=0.4']

View File

@ -143,14 +143,14 @@ class Sphinx(object):
try:
self._warning.write(warntext)
except UnicodeEncodeError:
encoding = getattr(self._warning, 'encoding', 'ascii')
encoding = getattr(self._warning, 'encoding', 'ascii') or 'ascii'
self._warning.write(warntext.encode(encoding, 'replace'))
def info(self, message='', nonl=False):
try:
self._status.write(message)
except UnicodeEncodeError:
encoding = getattr(self._status, 'encoding', 'ascii')
encoding = getattr(self._status, 'encoding', 'ascii') or 'ascii'
self._status.write(message.encode(encoding, 'replace'))
if not nonl:
self._status.write('\n')

View File

@ -176,7 +176,8 @@ class Builder(object):
if self.config.language is not None:
self.info(bold('loading translations [%s]... ' %
self.config.language), nonl=True)
locale_dirs = [path.join(package_dir, 'locale')] + \
# the None entry is the system's default locale path
locale_dirs = [None, path.join(package_dir, 'locale')] + \
[path.join(self.srcdir, x) for x in self.config.locale_dirs]
for dir_ in locale_dirs:
try:

View File

@ -1270,7 +1270,8 @@ class BuildEnvironment:
newnode['refuri'] = builder.get_relative_uri(
fromdocname, docname, typ) + '#' + labelid
newnode.append(contnode)
elif typ == 'mod':
elif typ == 'mod' or \
typ == 'obj' and target in self.modules:
docname, synopsis, platform, deprecated = \
self.modules.get(target, ('','','', ''))
if not docname:

View File

@ -35,6 +35,7 @@ HEADER = r'''%% Generated by Sphinx.
%(babel)s
%(fontpkg)s
%(fncychap)s
%(longtable)s
\usepackage{sphinx}
%(preamble)s
@ -112,9 +113,11 @@ class Table(object):
self.col = 0
self.colcount = 0
self.colspec = None
self.rowcount = 0
self.had_head = False
self.has_verbatim = False
self.caption = None
self.longtable = False
class Desc(object):
@ -142,6 +145,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
'babel': '\\usepackage{babel}',
'fontpkg': '\\usepackage{times}',
'fncychap': '\\usepackage[Bjarne]{fncychap}',
'longtable': '\\usepackage{longtable}',
'preamble': '',
'title': '',
'date': '',
@ -595,16 +599,21 @@ class LaTeXTranslator(nodes.NodeVisitor):
'%s:%s: nested tables are not yet implemented.' %
(self.curfilestack[-1], node.line or ''))
self.table = Table()
self.table.longtable = 'longtable' in node['classes']
self.tablebody = []
# Redirect body output until table is finished.
self._body = self.body
self.body = self.tablebody
def depart_table(self, node):
if self.table.rowcount > 30:
self.table.longtable = True
self.body = self._body
if self.table.caption is not None:
if not self.table.longtable and self.table.caption is not None:
self.body.append('\n\\begin{threeparttable}\n'
'\\caption{%s}\n' % self.table.caption)
if self.table.has_verbatim:
if self.table.longtable:
self.body.append('\n\\begin{longtable}')
elif self.table.has_verbatim:
self.body.append('\n\\begin{tabular}')
else:
self.body.append('\n\\begin{tabulary}{\\textwidth}')
@ -616,14 +625,35 @@ class LaTeXTranslator(nodes.NodeVisitor):
colspec = ('p{%.3f\\textwidth}|' % colwidth) * \
self.table.colcount
self.body.append('{|' + colspec + '}\n')
elif self.table.longtable:
self.body.append('{|' + ('l|' * self.table.colcount) + '}\n')
else:
self.body.append('{|' + ('L|' * self.table.colcount) + '}\n')
if self.table.longtable and self.table.caption is not None:
self.body.append('\\caption{%s} \\\\\n' % self.table.caption)
if self.table.longtable:
self.body.append('\\hline\n')
self.body.append('\\endfirsthead\n\n')
self.body.append('\multicolumn{%s}{c}%%\n' % self.table.colcount)
self.body.append('{{\\bfseries \\tablename\\ \\thetable{} -- %s}} \\\\\n' % _('continued from previous page'))
self.body.append('\\hline\n')
self.body.append('\\endhead\n\n')
self.body.append('\\hline \multicolumn{%s}{|r|}{{%s}} \\\\ \\hline\n' % (
self.table.colcount, _('Continued on next page')))
self.body.append('\\endfoot\n\n')
self.body.append('\\hline\n')
self.body.append('\\endlastfoot\n\n')
else:
self.body.append('\\hline\n')
self.body.extend(self.tablebody)
if self.table.has_verbatim:
if self.table.longtable:
self.body.append('\\end{longtable}\n\n')
elif self.table.has_verbatim:
self.body.append('\\end{tabular}\n\n')
else:
self.body.append('\\end{tabulary}\n\n')
if self.table.caption is not None:
if not self.table.longtable and self.table.caption is not None:
self.body.append('\\end{threeparttable}\n\n')
self.table = None
self.tablebody = None
@ -642,8 +672,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
if self.next_table_colspec:
self.table.colspec = '{%s}\n' % self.next_table_colspec
self.next_table_colspec = None
self.body.append('\\hline\n')
self.table.had_head = True
# self.body.append('\\hline\n')
# self.table.had_head = True
def depart_thead(self, node):
self.body.append('\\hline\n')
@ -657,6 +687,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.table.col = 0
def depart_row(self, node):
self.body.append('\\\\\n')
self.table.rowcount += 1
def visit_entry(self, node):
if node.has_key('morerows') or node.has_key('morecols'):