Merge branch '1.6-release'

Fixed conflicts:
	tests/test_build_html5.py

Also updated tests/test_build_latex.py
This commit is contained in:
jfbu 2017-05-11 11:40:06 +02:00
commit e277cb7285
22 changed files with 202 additions and 109 deletions

22
CHANGES
View File

@ -57,6 +57,9 @@ Release 1.6 beta4 (in development)
Incompatible changes
--------------------
* LaTeX package ``threeparttable`` is not used and not loaded by Sphinx
anymore (refs #3686, #3532, #3377)
Deprecated
----------
@ -70,6 +73,13 @@ Bugs fixed
----------
* LaTeX tables do not allow multiple paragraphs in a header cell
* LATEXOPTS is not passed over correctly to pdflatex since 1.6b3
* #3532: Figure or literal block captions in cells of short tables cause havoc
in PDF output
* Fix: in PDF captions of tables are rendered differently whether table is of
longtable class or not (refs #3686)
* #3725: Todo looks different from note in LaTeX output
* #3479: stub-columns have no effect in LaTeX output
Testing
--------
@ -91,8 +101,7 @@ Features added
--------------
* ``LATEXMKOPTS`` variable for the Makefile in ``$BUILDDIR/latex`` to pass
options to ``latexmk`` when executing ``make latexpdf``. Default is ``-f``.
(refs #3695)
options to ``latexmk`` when executing ``make latexpdf`` (refs #3695, #3720)
* Add a new event `env-check-consistency` to check consistency to extensions
* Add `Domain.check_consistency()` to check consistency
@ -141,7 +150,7 @@ Dependencies
* (updated) latex output is tested with Ubuntu trusty's texlive packages (Feb.
2014) and earlier tex installations may not be fully compliant, particularly
regarding Unicode engines xelatex and lualatex
* (added) latexmk is requirement for ``make latexpdf`` on Unix-like platforms
* (added) latexmk is required for ``make latexpdf`` on Unix-like platforms
(refs: #3082)
Incompatible changes
@ -232,8 +241,8 @@ Features added
* #3476: setuptools: Support multiple builders
* latex: merged cells in LaTeX tables allow code-blocks, lists, blockquotes...
as do normal cells (refs: #3435)
* HTML buildre uses experimental HTML5 writer if ``html_experimental_html5_writer`` is True
and docutils 0.13 and newer is installed.
* HTML builder uses experimental HTML5 writer if ``html_experimental_html5_writer`` is True
and docutils 0.13 or later is installed.
* LaTeX macros to customize space before and after tables in PDF output (refs #3504)
* #3348: Show decorators in literalinclude and viewcode directives
* #3108: Show warning if :start-at: and other literalinclude options does not
@ -254,6 +263,7 @@ Features added
Jeroen Demeyer.
* Add a new extension; ``sphinx.ext.imgconverter``. It converts images in the
document to appropriate format for builders
* latex: Use templates to render tables (refs #3389, 2a37b0e)
Bugs fixed
----------
@ -284,7 +294,7 @@ Deprecated
removed at Sphinx 1.7. Extension authors please use ``sphinxadmonition``
instead (as Sphinx does since 1.5.)
* ``Sphinx.status_iterator()`` and ``Sphinx.old_status_iterator()`` is now
deprecated. Please use ``sphinx.util:status_iterator()`` intead.
deprecated. Please use ``sphinx.util:status_iterator()`` instead.
* ``Sphinx._directive_helper()`` is deprecated. Please use
``sphinx.util.docutils.directive_helper()`` instead.
* ``BuildEnvironment.set_warnfunc()`` is now deprecated

View File

@ -182,30 +182,18 @@ The builder's "name" must be given to the **-b** command-line option of
.. versionchanged:: 1.6
Use of ``latexmk`` on GNU/Linux or Mac OS X.
Since 1.6, ``make latexpdf`` (or ``make -C "<builddir>/latex"`` after a
``sphinx-build`` run) uses ``latexmk`` (on GNU/Linux and Mac OS X).
It invokes it with option ``-f`` which attempts to complete targets
even in case of LaTeX processing errors. This can be overridden via
``LATEXMKOPTS`` variable, for example:
Since 1.6, and on GNU/Linux and Mac OS X, ``make latexpdf`` (or
``make -C "<builddir>/latex"`` after a ``sphinx-build`` run) uses
``latexmk``. One can pass to ``latexmk`` options via the ``LATEXMKOPTS``
Makefile variable. For example:
.. code-block:: console
make latexpdf LATEXMKOPTS=""
make latexpdf LATEXMKOPTS="-silent"
The ``pdflatex`` calls themselves obey the ``LATEXOPTS`` variable whose
default is ``--interaction=nonstopmode`` (same as ``-interaction
nonstopmode``.) In order to stop the
compilation on first error one can use ``--halt-on-error``.
Example:
.. code-block:: console
make latexpdf LATEXMKOPTS="-silent" LATEXOPTS="--halt-on-error"
In case the first ``pdflatex`` run aborts with an error, this will stop
further ``latexmk`` processing (no ``-f`` option). The console output
will be kept to a bare minimum during target processing (``-silent``).
reduces console output to a minimum. To pass options directly to the
``pdflatex`` executable, use variable ``LATEXOPTS`` (for example
``LATEXOPTS="--interaction=nonstopmode"``).
.. autoattribute:: name

View File

@ -1611,17 +1611,16 @@ These options influence LaTeX output. See further :doc:`latex`.
.. confval:: latex_use_latex_multicolumn
If ``False`` (default), the LaTeX writer uses for merged cells in grid
tables Sphinx's own macros. They have the advantage to allow the same
contents as in non-merged cells (inclusive of literal blocks, lists,
blockquotes, ...). But they assume that the columns are separated by the
standard vertical rule. Further, in case the :rst:dir:`tabularcolumns`
directive was employed to inject more macros (using LaTeX's mark-up of the
type ``>{..}``, ``<{..}``, ``@{..}``) the multicolumn cannot ignore these
extra macros, contrarily to LaTeX's own ``\multicolumn``; but Sphinx's
version does arrange for ignoring ``\columncolor`` like the standard
``\multicolumn`` does. Setting to ``True`` means to use LaTeX's standard
``\multicolumn`` macro.
The default is ``False``: it means that Sphinx's own macros are used for
merged cells from grid tables. They allow general contents (literal blocks,
lists, blockquotes, ...) but may have problems if the
:rst:dir:`tabularcolumns` directive was used to inject LaTeX mark-up of the
type ``>{..}``, ``<{..}``, ``@{..}`` as column specification.
Setting to ``True`` means to use LaTeX's standard ``\multicolumn``; this is
incompatible with literal blocks in the horizontally merged cell, and also
with multiple paragraphs in such cell if the table is rendered using
``tabulary``.
.. versionadded:: 1.6

View File

@ -20,6 +20,7 @@ from sphinx.locale import _
from sphinx.environment import NoUri
from sphinx.util import logging
from sphinx.util.nodes import set_source_info
from sphinx.util.texescape import tex_escape_map
from docutils.parsers.rst import Directive
from docutils.parsers.rst.directives.admonitions import BaseAdmonition
@ -209,6 +210,17 @@ def depart_todo_node(self, node):
self.depart_admonition(node)
def latex_visit_todo_node(self, node):
# type: (nodes.NodeVisitor, todo_node) -> None
title = node.pop(0).astext().translate(tex_escape_map)
self.body.append(u'\n\\begin{sphinxadmonition}{note}{%s:}' % title)
def latex_depart_todo_node(self, node):
# type: (nodes.NodeVisitor, todo_node) -> None
self.body.append('\\end{sphinxadmonition}\n')
def setup(app):
# type: (Sphinx) -> Dict[unicode, Any]
app.add_event('todo-defined')
@ -219,7 +231,7 @@ def setup(app):
app.add_node(todolist)
app.add_node(todo_node,
html=(visit_todo_node, depart_todo_node),
latex=(visit_todo_node, depart_todo_node),
latex=(latex_visit_todo_node, latex_depart_todo_node),
text=(visit_todo_node, depart_todo_node),
man=(visit_todo_node, depart_todo_node),
texinfo=(visit_todo_node, depart_todo_node))

View File

@ -11,8 +11,9 @@
\centering
<%- endif %>
<% if table.caption -%>
\begin{threeparttable}
\capstart\caption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxcapstartof{table}
\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxaftercaption
<% endif -%>
\begin{tabular}[t]<%= table.get_colspec() -%>
\hline
@ -22,8 +23,5 @@
<%- endif -%>
<%=- ''.join(table.body) %>
\end{tabular}
<%- if table.caption %>
\end{threeparttable}
<%- endif %>
\par
\sphinxattableend\end{savenotes}

View File

@ -11,8 +11,9 @@
\centering
<%- endif %>
<% if table.caption -%>
\begin{threeparttable}
\capstart\caption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxcapstartof{table}
\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxaftercaption
<% endif -%>
\begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%>
\hline
@ -22,8 +23,5 @@
<%- endif -%>
<%=- ''.join(table.body) %>
\end{tabulary}
<%- if table.caption %>
\end{threeparttable}
<%- endif %>
\par
\sphinxattableend\end{savenotes}

View File

@ -14,10 +14,10 @@ ALLIMGS = $(wildcard *.png *.gif *.jpg *.jpeg)
# Prefix for archive names
ARCHIVEPRREFIX =
# Additional LaTeX options (used via latexmkrc/latexmkjarc file)
LATEXOPTS = --interaction=nonstopmode
# Additional LaTeX options (passed via variables in latexmkrc/latexmkjarc file)
export LATEXOPTS =
# Additional latexmk options
LATEXMKOPTS = -f
LATEXMKOPTS =
# format: pdf or dvi
FMT = pdf

View File

@ -1,4 +1,4 @@
$latex = 'platex $LATEXOPTS -kanji=utf8 %O %S';
$latex = 'platex ' . $ENV{'LATEXOPTS'} . ' -kanji=utf8 %O %S';
$dvipdf = 'dvipdfmx %O -o %D %S';
$makeindex = 'rm -f %D; mendex -U -f -d %B.dic -s python.ist %S || echo "mendex exited with error code $? (ignoring)" && : >> %D';
add_cus_dep( "glo", "gls", 0, "makeglo" );

View File

@ -1,7 +1,7 @@
$latex = 'latex $LATEXOPTS %O %S';
$pdflatex = 'pdflatex $LATEXOPTS %O %S';
$lualatex = 'lualatex $LATEXOPTS %O %S';
$xelatex = 'xelatex --no-pdf $LATEXOPTS %O %S';
$latex = 'latex ' . $ENV{'LATEXOPTS'} . ' %O %S';
$pdflatex = 'pdflatex ' . $ENV{'LATEXOPTS'} . ' %O %S';
$lualatex = 'lualatex ' . $ENV{'LATEXOPTS'} . ' %O %S';
$xelatex = 'xelatex --no-pdf ' . $ENV{'LATEXOPTS'} . ' %O %S';
$makeindex = 'makeindex -s python.ist %O -o %D %S';
add_cus_dep( "glo", "gls", 0, "makeglo" );
sub makeglo {

View File

@ -77,40 +77,63 @@
#1\dimexpr\linewidth-\arrayrulewidth\relax-\tw@\tabcolsep-\arrayrulewidth\relax}}
% using here T (for Tabulary) feels less of a problem than the X could be
\newcolumntype{T}{J}%
% For tables allowing pagebreaks
\RequirePackage{longtable}
% For table captions.
\RequirePackage{threeparttable}
% fixing the LaTeX mess of vertical spaces with threeparttable and longtable
% The user interface:
% User interface to set-up whitespace before and after tables:
\newcommand*\sphinxtablepre {0pt}%
\newcommand*\sphinxtablepost{\medskipamount}%
\newcommand*\sphinxbelowcaptionspace{.5\sphinxbaselineskip}%
% as one can not use \baselineskip from inside longtable (it is zero there)
% we need \sphinxbaselineskip, which defaults to \baselineskip
\newcommand*\sphinxbelowcaptionspace{.5\sphinxbaselineskip}%
\def\sphinxbaselineskip{\baselineskip}%
% Helper macros, not a priori for user customization
% These commands are inserted by the table templates
\def\sphinxatlongtablestart
{\par
\vskip\parskip
\vskip\dimexpr\sphinxtablepre\relax % adjust vertical position
\vbox{}% get correct baseline from above
\LTpre\z@skip\LTpost\z@skip % set to zero longtable's own skips
\edef\sphinxbaselineskip{\dimexpr\the\dimexpr\baselineskip\relax\relax}}%
\edef\sphinxbaselineskip{\dimexpr\the\dimexpr\baselineskip\relax\relax}%
}%
\def\sphinxatlongtableend{\prevdepth\z@\vskip\sphinxtablepost\relax}%
% the longtable template inserts a \strut at caption's end
\def\sphinxlongtablecapskipadjust
{\dimexpr-\dp\strutbox-\sphinxbaselineskip
+\sphinxbelowcaptionspace\relax}%
% tabular(y) with or without threeparttable
{\dimexpr-\dp\strutbox-\sphinxbaselineskip+\sphinxbelowcaptionspace\relax}%
% Now for tables not using longtable
\def\sphinxattablestart
{\par
\vskip\dimexpr\sphinxtablepre\relax
\belowcaptionskip\sphinx@TPTbelowcaptionskip}%
}%
\let\sphinxattableend\sphinxatlongtableend
% the tabular(y) templates use [t] vertical placement parameter
\def\sphinx@TPTbelowcaptionskip
{\dimexpr-1.2\baselineskip % .2\baselineskip hardcoded in threeparttable
+\sphinxbelowcaptionspace\relax }%
% longtable's wraps captions to a maximal width of \LTcapwidth
% so we do the same for all tables
\newcommand*\sphinxcapstartof[1]{%
\vskip\parskip
\vbox{}% force baselineskip for good positioning by capstart of hyperanchor
\def\@captype{#1}%
\capstart
% move back vertically to compensate space inserted by next paragraph
\vskip-\baselineskip\vskip-\parskip
}%
\newcommand\sphinxcaption[2][\LTcapwidth]{%
\noindent\hb@xt@\linewidth{\hss
\vtop{\@tempdima\dimexpr#1\relax
% don't exceed linewidth for the caption width
\ifdim\@tempdima>\linewidth\hsize\linewidth\else\hsize\@tempdima\fi
% longtable ignores \abovecaptionskip/\belowcaptionskip, so do the same here
\abovecaptionskip\z@skip
\belowcaptionskip\z@skip
\caption[{#2}]%
{\strut\ignorespaces#2\ifhmode\unskip\@finalstrut\strutbox\fi}%
}\hss}%
\par\prevdepth\dp\strutbox
}%
\newcommand\sphinxaftercaption
{% this default definition serves with a caption *above* a table, to make sure
% its last baseline is \sphinxbelowcaptionspace above table top
\nobreak
\vskip\dimexpr\sphinxbelowcaptionspace\relax
\vskip-\baselineskip\vskip-\parskip
}%
% varwidth is crucial for our handling of general contents in merged cells
\RequirePackage{varwidth}
% but addition of a compatibility patch with hyperref is needed
@ -597,6 +620,7 @@
%
\newenvironment{sphinxfigure-in-table}[1][\linewidth]{%
\def\@captype{figure}%
\sphinxsetvskipsforfigintablecaption
\begin{minipage}{#1}%
}{\end{minipage}}
% store original \caption macro for use with figures in longtable and tabulary
@ -605,7 +629,9 @@
{\ifx\equation$%$% this is trick to identify tabulary first pass
\firstchoice@false\else\firstchoice@true\fi
\spx@originalcaption }
\newcommand*\sphinxsetvskipsforfigintablecaption
{\abovecaptionskip\smallskipamount
\belowcaptionskip\smallskipamount}
%% FOOTNOTES
%

View File

@ -332,6 +332,7 @@ class Table(object):
self.caption = None # type: List[unicode]
self.caption_footnotetexts = [] # type: List[unicode]
self.header_footnotetexts = [] # type: List[unicode]
self.stubs = [] # type: List[int]
# current position
self.col = 0
@ -1332,6 +1333,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.table.colcount += 1
if 'colwidth' in node:
self.table.colwidths.append(node['colwidth'])
if 'stub' in node:
self.table.stubs.append(self.table.colcount - 1)
def depart_colspec(self, node):
# type: (nodes.Node) -> None
@ -1442,7 +1445,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.needs_linetrimming = 1
if len(node.traverse(nodes.paragraph)) >= 2:
self.table.has_oldproblematic = True
if isinstance(node.parent.parent, nodes.thead):
if isinstance(node.parent.parent, nodes.thead) or (cell.col in self.table.stubs):
if len(node) == 1 and isinstance(node[0], nodes.paragraph) and node.astext() == '':
pass
else:

View File

@ -130,3 +130,22 @@ longtable having problematic cell
- cell2-2
* - cell3-1
- cell3-2
longtable having both stub columns and problematic cell
-------------------------------------------------------
.. list-table::
:class: longtable
:header-rows: 1
:stub-columns: 2
* - header1
- header2
- header3
* - + instub1-1a
+ instub1-1b
- instub1-2
- notinstub1-3
* - cell2-1
- cell2-2
- cell2-3

View File

@ -133,3 +133,21 @@ table having problematic cell
- cell2-2
* - cell3-1
- cell3-2
table having both stub columns and problematic cell
---------------------------------------------------
.. list-table::
:header-rows: 1
:stub-columns: 2
* - header1
- header2
- header3
* - + instub1-1a
+ instub1-1b
- instub1-2
- notinstub1-3
* - cell2-1
- cell2-2
- cell2-3

View File

@ -129,6 +129,7 @@ def test_pep_0420_disabled_top_level_verify(make_app, apidoc):
print(app._status.getvalue())
print(app._warning.getvalue())
@pytest.mark.apidoc(
coderoot=(rootdir / 'roots' / 'test-apidoc-trailing-underscore'))
def test_trailing_underscore(make_app, apidoc):
@ -147,6 +148,7 @@ def test_trailing_underscore(make_app, apidoc):
assert "package_ package\n" in rst
assert "package_.module_ module\n" in rst
@pytest.mark.apidoc(
coderoot=(rootdir / 'root'),
options=[

View File

@ -8,8 +8,6 @@
:copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import codecs
from docutils import nodes
from sphinx.application import ExtensionError

View File

@ -448,11 +448,13 @@ def test_html_output(app, cached_etree_parse, fname, expect):
app.build()
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
@pytest.mark.sphinx('html', testroot='build-html-translator')
def test_html_translator(app):
app.build()
assert app.builder.docwriter.visitor.depart_with_node == 10
@pytest.mark.parametrize("fname,expect", flat_dict({
'index.html': [
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True),
@ -1205,25 +1207,25 @@ def test_html_raw_directive(app, status, warning):
@pytest.mark.parametrize("fname,expect", flat_dict({
'index.html': [
(".//link[@href='_static/persistent.css']"
"[@rel='stylesheet']", '', True),
"[@rel='stylesheet']", '', True),
(".//link[@href='_static/default.css']"
"[@rel='stylesheet']"
"[@title='Default']", '', True),
"[@rel='stylesheet']"
"[@title='Default']", '', True),
(".//link[@href='_static/alternate1.css']"
"[@rel='alternate stylesheet']"
"[@title='Alternate']", '', True),
"[@rel='alternate stylesheet']"
"[@title='Alternate']", '', True),
(".//link[@href='_static/alternate2.css']"
"[@rel='alternate stylesheet']", '', True),
"[@rel='alternate stylesheet']", '', True),
(".//link[@href='_static/more_persistent.css']"
"[@rel='stylesheet']", '', True),
"[@rel='stylesheet']", '', True),
(".//link[@href='_static/more_default.css']"
"[@rel='stylesheet']"
"[@title='Default']", '', True),
"[@rel='stylesheet']"
"[@title='Default']", '', True),
(".//link[@href='_static/more_alternate1.css']"
"[@rel='alternate stylesheet']"
"[@title='Alternate']", '', True),
"[@rel='alternate stylesheet']"
"[@title='Alternate']", '', True),
(".//link[@href='_static/more_alternate2.css']"
"[@rel='alternate stylesheet']", '', True),
"[@rel='alternate stylesheet']", '', True),
],
}))
@pytest.mark.sphinx('html', testroot='stylesheets')

View File

@ -31,7 +31,7 @@ from test_build_html import ENV_WARNINGS
LATEX_ENGINES = ['pdflatex', 'lualatex', 'xelatex']
DOCCLASSES = ['howto', 'manual']
STYLEFILES = ['article.cls', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty',
'framed.sty', 'color.sty', 'fancyvrb.sty', 'threeparttable.sty',
'framed.sty', 'color.sty', 'fancyvrb.sty',
'fncychap.sty', 'geometry.sty', 'kvoptions.sty', 'hyperref.sty']
LATEX_WARNINGS = ENV_WARNINGS + """\
@ -492,7 +492,7 @@ def test_footnote(app, status, warning):
assert ('\\bibitem[bar]{\\detokenize{bar}}'
'{\\phantomsection\\label{\\detokenize{footnote:bar}} '
'\ncite\n}') in result
assert '\\caption{Table caption \\sphinxfootnotemark[4]' in result
assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result
assert ('\\hline%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n'
'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n'
'\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n'
@ -501,7 +501,7 @@ def test_footnote(app, status, warning):
assert ('Information about VIDIOC\\_CROPCAP %\n'
'\\begin{footnote}[6]\\sphinxAtStartFootnote\n'
'footnote in table not in header\n%\n\\end{footnote}\n\\\\\n\\hline\n'
'\\end{tabulary}\n\\end{threeparttable}\n'
'\\end{tabulary}\n'
'\\par\n\\sphinxattableend\\end{savenotes}\n') in result
@ -517,7 +517,8 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
'{\\hyperref[\\detokenize{index:authoryear}]'
'{\\sphinxcrossref{{[}AuthorYear{]}}}}.}' in result)
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result
assert ('\\sphinxcaption{The table title with a reference'
' to {[}AuthorYear{]}}' in result)
assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result
assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[4]}\n'
'\\label{\\detokenize{index:the-section-with-a-reference-to}}'
@ -527,8 +528,8 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
'\\sphinxfootnotemark[6].}\\label{\\detokenize{index:id27}}\\end{figure}\n'
'%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n'
'Footnote in caption\n%\n\\end{footnotetext}')in result
assert ('\\caption{footnote \\sphinxfootnotemark[7] '
'in caption of normal table}\\label{\\detokenize{index:id28}}') in result
assert ('\\sphinxcaption{footnote \\sphinxfootnotemark[7] in '
'caption of normal table}\\label{\\detokenize{index:id28}}') in result
assert ('\\caption{footnote \\sphinxfootnotemark[8] '
'in caption \\sphinxfootnotemark[9] of longtable\\strut}') in result
assert ('\\endlastfoot\n%\n\\begin{footnotetext}[8]\\sphinxAtStartFootnote\n'
@ -894,10 +895,12 @@ def test_latex_table_tabulars(app, status, warning):
# table having caption
table = tables['table having caption']
assert ('\\begin{savenotes}\\sphinxattablestart\n\\centering\n'
'\\begin{threeparttable}\n\\capstart\\caption{caption for table}'
'\\label{\\detokenize{tabular:id1}}' in table)
'\\sphinxcapstartof{table}\n'
'\\sphinxcaption{caption for table}'
'\\label{\\detokenize{tabular:id1}}\n'
'\\sphinxaftercaption' in table)
assert ('\\begin{tabulary}{\\linewidth}[t]{|T|T|}' in table)
assert ('\\hline\n\\end{tabulary}\n\\end{threeparttable}'
assert ('\\hline\n\\end{tabulary}'
'\n\\par\n\\sphinxattableend\\end{savenotes}' in table)
# table having verbatim
@ -912,6 +915,13 @@ def test_latex_table_tabulars(app, status, warning):
table = tables['table having both :widths: and problematic cell']
assert ('\\begin{tabular}[t]{|\\X{30}{100}|\\X{70}{100}|}' in table)
# table having both stub columns and problematic cell
table = tables['table having both stub columns and problematic cell']
assert ('&\\sphinxstyletheadfamily \n'
'instub1-2\n&\nnotinstub1-3\n\\\\\n'
'\\hline\\sphinxstyletheadfamily \n'
'cell2-1\n&' in table)
@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
reason='docutils-0.13 or above is required')
@ -976,6 +986,13 @@ def test_latex_table_longtable(app, status, warning):
table = tables['longtable having both :widths: and problematic cell']
assert ('\\begin{longtable}{|\\X{30}{100}|\\X{70}{100}|}' in table)
# longtable having both stub columns and problematic cell
table = tables['longtable having both stub columns and problematic cell']
assert ('&\\sphinxstyletheadfamily \n'
'instub1-2\n&\nnotinstub1-3\n\\\\\n'
'\\hline\\sphinxstyletheadfamily \n'
'cell2-1\n&' in table)
@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
reason='docutils-0.13 or above is required')

View File

@ -517,4 +517,3 @@ def test_literalinclude_pydecorators(app, status, warning):
' pass\n'
)
assert actual == expect

View File

@ -537,6 +537,7 @@ def test_templates():
{2:'IDpE8Numerics'})
def test_template_args():
# from breathe#218
check('function',
@ -550,6 +551,7 @@ def test_template_args():
{2:"I0E21enable_if_not_array_t"})
def test_attributes():
# style: C++
check('member', '[[]] int f', {1:'f__i', 2:'1f'})

View File

@ -122,21 +122,21 @@ def test_domain_js_find_obj(app, status, warning):
assert (find_obj(None, None, u'NONEXISTANT', u'class') ==
(None, None))
assert (find_obj(None, None, u'NestedParentA', u'class') ==
( u'NestedParentA', (u'roles', u'class')))
(u'NestedParentA', (u'roles', u'class')))
assert (find_obj(None, None, u'NestedParentA.NestedChildA', u'class') ==
( u'NestedParentA.NestedChildA', (u'roles', u'class')))
(u'NestedParentA.NestedChildA', (u'roles', u'class')))
assert (find_obj(None, 'NestedParentA', u'NestedChildA', u'class') ==
( u'NestedParentA.NestedChildA', (u'roles', u'class')))
(u'NestedParentA.NestedChildA', (u'roles', u'class')))
assert (find_obj(None, None, u'NestedParentA.NestedChildA.subchild_1', u'func') ==
( u'NestedParentA.NestedChildA.subchild_1', (u'roles', u'function')))
(u'NestedParentA.NestedChildA.subchild_1', (u'roles', u'function')))
assert (find_obj(None, u'NestedParentA', u'NestedChildA.subchild_1', u'func') ==
( u'NestedParentA.NestedChildA.subchild_1', (u'roles', u'function')))
(u'NestedParentA.NestedChildA.subchild_1', (u'roles', u'function')))
assert (find_obj(None, u'NestedParentA.NestedChildA', u'subchild_1', u'func') ==
( u'NestedParentA.NestedChildA.subchild_1', (u'roles', u'function')))
(u'NestedParentA.NestedChildA.subchild_1', (u'roles', u'function')))
assert (find_obj(u'module_a.submodule', u'ModTopLevel', u'mod_child_2', u'meth') ==
( u'module_a.submodule.ModTopLevel.mod_child_2', (u'module', u'method')))
(u'module_a.submodule.ModTopLevel.mod_child_2', (u'module', u'method')))
assert (find_obj(u'module_b.submodule', u'ModTopLevel', u'module_a.submodule', u'mod') ==
( u'module_a.submodule', (u'module', u'module')))
(u'module_a.submodule', (u'module', u'module')))
def test_get_full_qualified_name():

View File

@ -106,16 +106,16 @@ def test_get_items_summary(app, status, warning):
'dummy_module.func')
assert autosummary_items['func'] == func_attrs
def str_content(elem):
if elem.text is not None:
return elem.text
else:
return ''.join(str_content(e) for e in elem)
@pytest.mark.sphinx('xml', **default_kw)
def test_escaping(app, status, warning):
from xml.etree import ElementTree
app.builder.build_all()
outdir = app.builder.outdir

View File

@ -10,6 +10,7 @@
"""
from unittest import TestCase
import sys
from six import PY3
import functools
from textwrap import dedent
@ -17,6 +18,7 @@ import pytest
from sphinx.util import inspect
class TestGetArgSpec(TestCase):
def test_getargspec_builtin_type(self):
with pytest.raises(TypeError):
@ -64,7 +66,7 @@ class TestGetArgSpec(TestCase):
pass
assert expected_unbound == inspect.getargspec(Foo.method)
if PY3:
if PY3 and sys.version_info >= (3, 4, 4):
# On py2, the inspect functions don't properly handle bound
# methods (they include a spurious 'self' argument)
assert expected_bound == inspect.getargspec(bound_method)