mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#565: In the LaTeX builder, not only literal blocks require different table handling, but also quite a few other list-like block elements.
This commit is contained in:
parent
a4036ae6ad
commit
6964bdffb9
3
CHANGES
3
CHANGES
@ -1,6 +1,9 @@
|
|||||||
Release 1.0.6 (in development)
|
Release 1.0.6 (in development)
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
* #565: In the LaTeX builder, not only literal blocks require different
|
||||||
|
table handling, but also quite a few other list-like block elements.
|
||||||
|
|
||||||
* #515: Fix tracebacks in the viewcode extension for Python objects
|
* #515: Fix tracebacks in the viewcode extension for Python objects
|
||||||
that do not have a valid signature.
|
that do not have a valid signature.
|
||||||
|
|
||||||
|
@ -124,9 +124,10 @@ following directive exists:
|
|||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
Tables that contain literal blocks cannot be set with ``tabulary``. They are
|
Tables that contain block-level elements such as object descriptions, literal
|
||||||
therefore set with the standard LaTeX ``tabular`` environment. Also, the
|
blocks, blockquotes or any kind of lists cannot be set with ``tabulary``.
|
||||||
verbatim environment used for literal blocks only works in ``p{width}``
|
They are therefore set with the standard LaTeX ``tabular`` environment.
|
||||||
columns, which means that by default, Sphinx generates such column specs for
|
Also, the verbatim environment used for literal blocks only works in
|
||||||
such tables. Use the :rst:dir:`tabularcolumns` directive to get finer control
|
``p{width}`` columns, which means that by default, Sphinx generates such
|
||||||
over such tables.
|
column specs for such tables. Use the :rst:dir:`tabularcolumns` directive to
|
||||||
|
get finer control over such tables.
|
||||||
|
@ -113,7 +113,7 @@ class Table(object):
|
|||||||
self.colspec = None
|
self.colspec = None
|
||||||
self.rowcount = 0
|
self.rowcount = 0
|
||||||
self.had_head = False
|
self.had_head = False
|
||||||
self.has_verbatim = False
|
self.has_problematic = False
|
||||||
self.caption = None
|
self.caption = None
|
||||||
self.longtable = False
|
self.longtable = False
|
||||||
|
|
||||||
@ -482,6 +482,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def visit_desc(self, node):
|
def visit_desc(self, node):
|
||||||
self.body.append('\n\n\\begin{fulllineitems}\n')
|
self.body.append('\n\n\\begin{fulllineitems}\n')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_desc(self, node):
|
def depart_desc(self, node):
|
||||||
self.body.append('\n\\end{fulllineitems}\n\n')
|
self.body.append('\n\\end{fulllineitems}\n\n')
|
||||||
|
|
||||||
@ -615,14 +617,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
u'\\capstart\\caption{%s}\n' % self.table.caption)
|
u'\\capstart\\caption{%s}\n' % self.table.caption)
|
||||||
if self.table.longtable:
|
if self.table.longtable:
|
||||||
self.body.append('\n\\begin{longtable}')
|
self.body.append('\n\\begin{longtable}')
|
||||||
elif self.table.has_verbatim:
|
elif self.table.has_problematic:
|
||||||
self.body.append('\n\\begin{tabular}')
|
self.body.append('\n\\begin{tabular}')
|
||||||
else:
|
else:
|
||||||
self.body.append('\n\\begin{tabulary}{\\linewidth}')
|
self.body.append('\n\\begin{tabulary}{\\linewidth}')
|
||||||
if self.table.colspec:
|
if self.table.colspec:
|
||||||
self.body.append(self.table.colspec)
|
self.body.append(self.table.colspec)
|
||||||
else:
|
else:
|
||||||
if self.table.has_verbatim:
|
if self.table.has_problematic:
|
||||||
colwidth = 0.95 / self.table.colcount
|
colwidth = 0.95 / self.table.colcount
|
||||||
colspec = ('p{%.3f\\linewidth}|' % colwidth) * \
|
colspec = ('p{%.3f\\linewidth}|' % colwidth) * \
|
||||||
self.table.colcount
|
self.table.colcount
|
||||||
@ -657,7 +659,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.extend(self.tablebody)
|
self.body.extend(self.tablebody)
|
||||||
if self.table.longtable:
|
if self.table.longtable:
|
||||||
self.body.append('\\end{longtable}\n\n')
|
self.body.append('\\end{longtable}\n\n')
|
||||||
elif self.table.has_verbatim:
|
elif self.table.has_problematic:
|
||||||
self.body.append('\\end{tabular}\n\n')
|
self.body.append('\\end{tabular}\n\n')
|
||||||
else:
|
else:
|
||||||
self.body.append('\\end{tabulary}\n\n')
|
self.body.append('\\end{tabulary}\n\n')
|
||||||
@ -725,6 +727,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
def visit_bullet_list(self, node):
|
def visit_bullet_list(self, node):
|
||||||
if not self.compact_list:
|
if not self.compact_list:
|
||||||
self.body.append('\\begin{itemize}\n' )
|
self.body.append('\\begin{itemize}\n' )
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_bullet_list(self, node):
|
def depart_bullet_list(self, node):
|
||||||
if not self.compact_list:
|
if not self.compact_list:
|
||||||
self.body.append('\\end{itemize}\n' )
|
self.body.append('\\end{itemize}\n' )
|
||||||
@ -733,6 +737,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.append('\\begin{enumerate}\n' )
|
self.body.append('\\begin{enumerate}\n' )
|
||||||
if 'start' in node:
|
if 'start' in node:
|
||||||
self.body.append('\\setcounter{enumi}{%d}\n' % (node['start'] - 1))
|
self.body.append('\\setcounter{enumi}{%d}\n' % (node['start'] - 1))
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_enumerated_list(self, node):
|
def depart_enumerated_list(self, node):
|
||||||
self.body.append('\\end{enumerate}\n' )
|
self.body.append('\\end{enumerate}\n' )
|
||||||
|
|
||||||
@ -745,6 +751,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def visit_definition_list(self, node):
|
def visit_definition_list(self, node):
|
||||||
self.body.append('\\begin{description}\n')
|
self.body.append('\\begin{description}\n')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_definition_list(self, node):
|
def depart_definition_list(self, node):
|
||||||
self.body.append('\\end{description}\n')
|
self.body.append('\\end{description}\n')
|
||||||
|
|
||||||
@ -774,6 +782,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def visit_field_list(self, node):
|
def visit_field_list(self, node):
|
||||||
self.body.append('\\begin{quote}\\begin{description}\n')
|
self.body.append('\\begin{quote}\\begin{description}\n')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_field_list(self, node):
|
def depart_field_list(self, node):
|
||||||
self.body.append('\\end{description}\\end{quote}\n')
|
self.body.append('\\end{description}\\end{quote}\n')
|
||||||
|
|
||||||
@ -795,6 +805,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def visit_centered(self, node):
|
def visit_centered(self, node):
|
||||||
self.body.append('\n\\begin{center}')
|
self.body.append('\n\\begin{center}')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_centered(self, node):
|
def depart_centered(self, node):
|
||||||
self.body.append('\n\\end{center}')
|
self.body.append('\n\\end{center}')
|
||||||
|
|
||||||
@ -804,6 +816,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.compact_list += 1
|
self.compact_list += 1
|
||||||
self.body.append('\\begin{itemize}\\setlength{\\itemsep}{0pt}'
|
self.body.append('\\begin{itemize}\\setlength{\\itemsep}{0pt}'
|
||||||
'\\setlength{\\parskip}{0pt}\n')
|
'\\setlength{\\parskip}{0pt}\n')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_hlist(self, node):
|
def depart_hlist(self, node):
|
||||||
self.compact_list -= 1
|
self.compact_list -= 1
|
||||||
self.body.append('\\end{itemize}\n')
|
self.body.append('\\end{itemize}\n')
|
||||||
@ -1220,7 +1234,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
if self.table:
|
if self.table:
|
||||||
hlcode = hlcode.replace('\\begin{Verbatim}',
|
hlcode = hlcode.replace('\\begin{Verbatim}',
|
||||||
'\\begin{OriginalVerbatim}')
|
'\\begin{OriginalVerbatim}')
|
||||||
self.table.has_verbatim = True
|
self.table.has_problematic = True
|
||||||
# get consistent trailer
|
# get consistent trailer
|
||||||
hlcode = hlcode.rstrip()[:-14] # strip \end{Verbatim}
|
hlcode = hlcode.rstrip()[:-14] # strip \end{Verbatim}
|
||||||
hlcode = hlcode.rstrip() + '\n'
|
hlcode = hlcode.rstrip() + '\n'
|
||||||
@ -1241,6 +1255,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
'\\begin{DUlineblock}{\\DUlineblockindent}\n')
|
'\\begin{DUlineblock}{\\DUlineblockindent}\n')
|
||||||
else:
|
else:
|
||||||
self.body.append('\n\\begin{DUlineblock}{0em}\n')
|
self.body.append('\n\\begin{DUlineblock}{0em}\n')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_line_block(self, node):
|
def depart_line_block(self, node):
|
||||||
self.body.append('\\end{DUlineblock}\n')
|
self.body.append('\\end{DUlineblock}\n')
|
||||||
|
|
||||||
@ -1256,6 +1272,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
done = 1
|
done = 1
|
||||||
if not done:
|
if not done:
|
||||||
self.body.append('\\begin{quote}\n')
|
self.body.append('\\begin{quote}\n')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_block_quote(self, node):
|
def depart_block_quote(self, node):
|
||||||
done = 0
|
done = 0
|
||||||
if len(node.children) == 1:
|
if len(node.children) == 1:
|
||||||
@ -1292,6 +1310,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def visit_option_list(self, node):
|
def visit_option_list(self, node):
|
||||||
self.body.append('\\begin{optionlist}{3cm}\n')
|
self.body.append('\\begin{optionlist}{3cm}\n')
|
||||||
|
if self.table:
|
||||||
|
self.table.has_problematic = True
|
||||||
def depart_option_list(self, node):
|
def depart_option_list(self, node):
|
||||||
self.body.append('\\end{optionlist}\n')
|
self.body.append('\\end{optionlist}\n')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user