2010-01-17 05:29:00 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_build_latex
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the build process with LaTeX builder with the test root.
|
|
|
|
|
2016-01-14 15:54:04 -06:00
|
|
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
2010-01-17 05:29:00 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
2014-01-19 04:17:10 -06:00
|
|
|
from __future__ import print_function
|
2010-01-17 05:29:00 -06:00
|
|
|
|
|
|
|
import os
|
2010-06-03 10:25:16 -05:00
|
|
|
import re
|
2016-07-13 07:15:16 -05:00
|
|
|
from itertools import product
|
2010-01-17 05:29:00 -06:00
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
from six import PY3
|
2014-04-28 21:46:47 -05:00
|
|
|
|
2016-01-05 01:48:22 -06:00
|
|
|
from sphinx.errors import SphinxError
|
2016-07-13 07:15:16 -05:00
|
|
|
from sphinx.util.osutil import cd, ensuredir
|
2010-01-17 05:29:00 -06:00
|
|
|
from sphinx.writers.latex import LaTeXTranslator
|
|
|
|
|
2016-05-30 05:53:59 -05:00
|
|
|
from util import SkipTest, remove_unicode_literals, with_app, strip_escseq
|
2010-01-17 05:29:00 -06:00
|
|
|
from test_build_html import ENV_WARNINGS
|
|
|
|
|
|
|
|
|
2016-07-13 07:15:16 -05:00
|
|
|
LATEX_ENGINES = ['pdflatex', 'lualatex', 'xelatex']
|
|
|
|
DOCCLASSES = ['howto', 'manual']
|
2016-10-11 04:59:12 -05:00
|
|
|
STYLEFILES = ['article.sty', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty',
|
|
|
|
'framed.sty', 'color.sty', 'fancyvrb.sty', 'fncychap.sty',
|
|
|
|
'threeparttable.sty', 'geometry.sty']
|
2016-07-13 07:15:16 -05:00
|
|
|
|
2010-01-17 05:29:00 -06:00
|
|
|
LATEX_WARNINGS = ENV_WARNINGS + """\
|
2016-07-14 09:12:57 -05:00
|
|
|
%(root)s/index.rst:\\d+: WARNING: unknown option: &option
|
|
|
|
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
|
|
|
|
%(root)s/index.rst:\\d+: WARNING: no matching candidate for image URI u'foo.\\*'
|
|
|
|
%(root)s/index.rst:\\d+: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
2010-01-17 05:29:00 -06:00
|
|
|
"""
|
|
|
|
|
2014-04-30 07:30:46 -05:00
|
|
|
if PY3:
|
2010-06-20 15:39:38 -05:00
|
|
|
LATEX_WARNINGS = remove_unicode_literals(LATEX_WARNINGS)
|
|
|
|
|
2010-01-17 05:29:00 -06:00
|
|
|
|
2016-07-13 07:15:16 -05:00
|
|
|
# only run latex if all needed packages are there
|
|
|
|
def kpsetest(*filenames):
|
2016-01-15 03:48:49 -06:00
|
|
|
try:
|
2016-07-13 07:15:16 -05:00
|
|
|
p = Popen(['kpsewhich'] + list(filenames), stdout=PIPE)
|
|
|
|
except OSError:
|
|
|
|
# no kpsewhich... either no tex distribution is installed or it is
|
|
|
|
# a "strange" one -- don't bother running latex
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
p.communicate()
|
|
|
|
if p.returncode != 0:
|
|
|
|
# not found
|
|
|
|
return False
|
|
|
|
# found
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def test_latex():
|
|
|
|
if kpsetest(*STYLEFILES) is False:
|
|
|
|
raise SkipTest('not running latex, the required styles doesn\'t seem to be installed')
|
|
|
|
|
|
|
|
for engine, docclass in product(LATEX_ENGINES, DOCCLASSES):
|
|
|
|
yield build_latex_doc, engine, docclass
|
2016-01-15 13:34:29 -06:00
|
|
|
|
2016-06-11 10:00:52 -05:00
|
|
|
|
2016-07-14 09:12:57 -05:00
|
|
|
@with_app(buildername='latex')
|
2016-07-13 07:15:16 -05:00
|
|
|
def build_latex_doc(app, status, warning, engine, docclass):
|
|
|
|
app.config.latex_engine = engine
|
|
|
|
app.config.latex_documents[0] = app.config.latex_documents[0][:4] + (docclass,)
|
|
|
|
|
2010-01-17 05:29:00 -06:00
|
|
|
LaTeXTranslator.ignore_missing_images = True
|
|
|
|
app.builder.build_all()
|
2010-07-27 12:07:51 -05:00
|
|
|
|
2010-01-17 05:29:00 -06:00
|
|
|
# file from latex_additional_files
|
|
|
|
assert (app.outdir / 'svgimg.svg').isfile()
|
|
|
|
|
2016-07-13 07:15:16 -05:00
|
|
|
# now, try to run latex over it
|
|
|
|
with cd(app.outdir):
|
2010-01-17 05:29:00 -06:00
|
|
|
try:
|
2016-07-13 07:15:16 -05:00
|
|
|
ensuredir(engine)
|
|
|
|
p = Popen([engine, '--interaction=nonstopmode',
|
|
|
|
'-output-directory=%s' % engine, 'SphinxTests.tex'],
|
|
|
|
stdout=PIPE, stderr=PIPE)
|
|
|
|
except OSError: # most likely the latex executable was not found
|
|
|
|
raise SkipTest
|
2010-01-17 05:29:00 -06:00
|
|
|
else:
|
2016-07-13 07:15:16 -05:00
|
|
|
stdout, stderr = p.communicate()
|
2010-01-17 05:29:00 -06:00
|
|
|
if p.returncode != 0:
|
2016-07-13 07:15:16 -05:00
|
|
|
print(stdout)
|
|
|
|
print(stderr)
|
|
|
|
assert False, '%s exited with return code %s' % (
|
|
|
|
engine, p.returncode)
|
2014-09-26 22:47:27 -05:00
|
|
|
|
|
|
|
|
2016-05-03 07:31:43 -05:00
|
|
|
@with_app(buildername='latex')
|
|
|
|
def test_writer(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
|
|
|
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n'
|
2016-06-19 04:02:39 -05:00
|
|
|
'\\noindent\\sphinxincludegraphics{{img}.png}\n'
|
|
|
|
'\\sphinxfigcaption{figure in table}\\label{markup:id7}'
|
|
|
|
'\\end{sphinxfigure-in-table}\\relax' in result)
|
2016-06-02 09:57:14 -05:00
|
|
|
|
2016-05-03 11:21:16 -05:00
|
|
|
assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n'
|
2016-06-19 04:02:39 -05:00
|
|
|
'\\noindent\\sphinxincludegraphics{{rimg}.png}\n'
|
|
|
|
'\\caption{figure with align option}\\label{markup:id8}'
|
|
|
|
'\\end{wrapfigure}' in result)
|
2016-05-03 11:21:16 -05:00
|
|
|
|
2016-05-03 07:31:43 -05:00
|
|
|
assert ('\\begin{wrapfigure}{r}{0.500\\linewidth}\n\\centering\n'
|
2016-06-19 04:02:39 -05:00
|
|
|
'\\noindent\\sphinxincludegraphics{{rimg}.png}\n'
|
|
|
|
'\\caption{figure with align \\& figwidth option}\\label{markup:id9}'
|
|
|
|
'\\end{wrapfigure}' in result)
|
2016-05-03 07:31:43 -05:00
|
|
|
|
2016-05-29 23:13:38 -05:00
|
|
|
assert ('\\begin{wrapfigure}{r}{3cm}\n\\centering\n'
|
2016-06-19 04:02:39 -05:00
|
|
|
'\\noindent\\sphinxincludegraphics[width=3cm]{{rimg}.png}\n'
|
|
|
|
'\\caption{figure with align \\& width option}\\label{markup:id10}'
|
|
|
|
'\\end{wrapfigure}' in result)
|
2016-05-03 07:31:43 -05:00
|
|
|
|
|
|
|
|
2016-07-14 09:12:57 -05:00
|
|
|
@with_app(buildername='latex', testroot='warnings', freshenv=True)
|
|
|
|
def test_latex_warnings(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2016-07-14 10:51:29 -05:00
|
|
|
warnings = strip_escseq(warning.getvalue().replace(os.sep, '/'))
|
2016-07-14 09:12:57 -05:00
|
|
|
warnings_exp = LATEX_WARNINGS % {
|
|
|
|
'root': re.escape(app.srcdir.replace(os.sep, '/'))}
|
|
|
|
assert re.match(warnings_exp + '$', warnings), \
|
|
|
|
'Warnings don\'t match:\n' + \
|
|
|
|
'--- Expected (regex):\n' + warnings_exp + \
|
|
|
|
'--- Got:\n' + warnings
|
|
|
|
|
|
|
|
|
2014-10-01 21:17:34 -05:00
|
|
|
@with_app(buildername='latex', testroot='numfig',
|
|
|
|
confoverrides={'numfig': True})
|
|
|
|
def test_numref(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.\\@ }}' in result
|
2015-03-07 17:30:09 -06:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table }}' in result
|
2016-06-11 12:15:47 -05:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Listing }}' in result
|
2016-05-27 23:23:37 -05:00
|
|
|
assert '\\hyperref[index:fig1]{Fig.\\@ \\ref{index:fig1}}' in result
|
2015-03-02 09:53:06 -06:00
|
|
|
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
|
|
|
assert '\\hyperref[index:table-1]{Table \\ref{index:table-1}}' in result
|
|
|
|
assert '\\hyperref[baz:table22]{Table:\\ref{baz:table22}}' in result
|
|
|
|
assert '\\hyperref[index:code-1]{Listing \\ref{index:code-1}}' in result
|
|
|
|
assert '\\hyperref[baz:code22]{Code-\\ref{baz:code22}}' in result
|
2016-06-20 22:39:37 -05:00
|
|
|
assert '\\hyperref[foo:foo]{Section \\ref{foo:foo}}' in result
|
|
|
|
assert '\\hyperref[bar:bar-a]{Section \\ref{bar:bar-a}}' in result
|
2016-09-17 00:58:43 -05:00
|
|
|
assert '\\hyperref[index:fig1]{Fig.\\ref{index:fig1} \\nameref{index:fig1}}' in result
|
|
|
|
assert '\\hyperref[foo:foo]{Sect.\\ref{foo:foo} \\nameref{foo:foo}}' in result
|
2015-02-22 09:29:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='numfig',
|
|
|
|
confoverrides={'numfig': True,
|
|
|
|
'numfig_format': {'figure': 'Figure:%s',
|
|
|
|
'table': 'Tab_%s',
|
2016-06-20 22:39:37 -05:00
|
|
|
'code-block': 'Code-%s',
|
|
|
|
'section': 'SECTION-%s'}})
|
2015-02-22 09:29:05 -06:00
|
|
|
def test_numref_with_prefix1(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2015-03-07 17:30:09 -06:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Figure:}}' in result
|
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Tab\\_}}' in result
|
2016-06-11 12:15:47 -05:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Code-}}' in result
|
2015-02-22 09:29:05 -06:00
|
|
|
assert '\\ref{index:fig1}' in result
|
|
|
|
assert '\\ref{baz:fig22}' in result
|
|
|
|
assert '\\ref{index:table-1}' in result
|
|
|
|
assert '\\ref{baz:table22}' in result
|
|
|
|
assert '\\ref{index:code-1}' in result
|
|
|
|
assert '\\ref{baz:code22}' in result
|
2015-03-02 09:53:06 -06:00
|
|
|
assert '\\hyperref[index:fig1]{Figure:\\ref{index:fig1}}' in result
|
|
|
|
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
|
|
|
assert '\\hyperref[index:table-1]{Tab\\_\\ref{index:table-1}}' in result
|
|
|
|
assert '\\hyperref[baz:table22]{Table:\\ref{baz:table22}}' in result
|
|
|
|
assert '\\hyperref[index:code-1]{Code-\\ref{index:code-1}}' in result
|
|
|
|
assert '\\hyperref[baz:code22]{Code-\\ref{baz:code22}}' in result
|
2016-06-20 22:39:37 -05:00
|
|
|
assert '\\hyperref[foo:foo]{SECTION-\\ref{foo:foo}}' in result
|
|
|
|
assert '\\hyperref[bar:bar-a]{SECTION-\\ref{bar:bar-a}}' in result
|
2016-09-17 00:58:43 -05:00
|
|
|
assert '\\hyperref[index:fig1]{Fig.\\ref{index:fig1} \\nameref{index:fig1}}' in result
|
|
|
|
assert '\\hyperref[foo:foo]{Sect.\\ref{foo:foo} \\nameref{foo:foo}}' in result
|
2015-02-22 09:29:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='numfig',
|
|
|
|
confoverrides={'numfig': True,
|
|
|
|
'numfig_format': {'figure': 'Figure:%s.',
|
|
|
|
'table': 'Tab_%s:',
|
2016-06-20 22:39:37 -05:00
|
|
|
'code-block': 'Code-%s | ',
|
|
|
|
'section': 'SECTION_%s_'}})
|
2015-02-22 09:29:05 -06:00
|
|
|
def test_numref_with_prefix2(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2015-03-07 17:30:09 -06:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Figure:}}' in result
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\def\\fnum@figure{\\figurename\\thefigure.\\@}' in result
|
2015-03-07 17:30:09 -06:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Tab\\_}}' in result
|
2015-02-22 09:29:05 -06:00
|
|
|
assert '\\def\\fnum@table{\\tablename\\thetable:}' in result
|
2016-06-11 12:15:47 -05:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Code-}}' in result
|
2016-05-27 23:23:37 -05:00
|
|
|
assert '\\hyperref[index:fig1]{Figure:\\ref{index:fig1}.\\@}' in result
|
2015-03-02 09:53:06 -06:00
|
|
|
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
|
|
|
assert '\\hyperref[index:table-1]{Tab\\_\\ref{index:table-1}:}' in result
|
|
|
|
assert '\\hyperref[baz:table22]{Table:\\ref{baz:table22}}' in result
|
|
|
|
assert '\\hyperref[index:code-1]{Code-\\ref{index:code-1} \\textbar{} }' in result
|
|
|
|
assert '\\hyperref[baz:code22]{Code-\\ref{baz:code22}}' in result
|
2016-06-20 22:39:37 -05:00
|
|
|
assert '\\hyperref[foo:foo]{SECTION\\_\\ref{foo:foo}\\_}' in result
|
|
|
|
assert '\\hyperref[bar:bar-a]{SECTION\\_\\ref{bar:bar-a}\\_}' in result
|
2016-09-17 00:58:43 -05:00
|
|
|
assert '\\hyperref[index:fig1]{Fig.\\ref{index:fig1} \\nameref{index:fig1}}' in result
|
|
|
|
assert '\\hyperref[foo:foo]{Sect.\\ref{foo:foo} \\nameref{foo:foo}}' in result
|
2014-10-01 21:17:34 -05:00
|
|
|
|
|
|
|
|
2015-03-07 17:30:09 -06:00
|
|
|
@with_app(buildername='latex', testroot='numfig',
|
|
|
|
confoverrides={'numfig': True, 'language': 'ja'})
|
|
|
|
def test_numref_with_language_ja(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2015-03-09 07:46:34 -05:00
|
|
|
assert u'\\renewcommand{\\figurename}{\u56f3 }' in result
|
|
|
|
assert '\\renewcommand{\\tablename}{TABLE }' in result
|
2016-06-11 12:15:47 -05:00
|
|
|
assert '\\renewcommand{\\literalblockname}{LIST }' in result
|
2015-03-09 07:46:34 -05:00
|
|
|
assert u'\\hyperref[index:fig1]{\u56f3 \\ref{index:fig1}}' in result
|
2015-03-07 17:30:09 -06:00
|
|
|
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
2015-03-09 07:46:34 -05:00
|
|
|
assert '\\hyperref[index:table-1]{TABLE \\ref{index:table-1}}' in result
|
2015-03-07 17:30:09 -06:00
|
|
|
assert '\\hyperref[baz:table22]{Table:\\ref{baz:table22}}' in result
|
2015-03-09 07:46:34 -05:00
|
|
|
assert '\\hyperref[index:code-1]{LIST \\ref{index:code-1}}' in result
|
2015-03-07 17:30:09 -06:00
|
|
|
assert '\\hyperref[baz:code22]{Code-\\ref{baz:code22}}' in result
|
2016-06-20 22:39:37 -05:00
|
|
|
assert '\\hyperref[foo:foo]{Section \\ref{foo:foo}}' in result
|
|
|
|
assert '\\hyperref[bar:bar-a]{Section \\ref{bar:bar-a}}' in result
|
2016-09-17 00:58:43 -05:00
|
|
|
assert '\\hyperref[index:fig1]{Fig.\\ref{index:fig1} \\nameref{index:fig1}}' in result
|
|
|
|
assert '\\hyperref[foo:foo]{Sect.\\ref{foo:foo} \\nameref{foo:foo}}' in result
|
2015-03-07 17:30:09 -06:00
|
|
|
|
|
|
|
|
2014-09-26 22:47:27 -05:00
|
|
|
@with_app(buildername='latex')
|
|
|
|
def test_latex_add_latex_package(app, status, warning):
|
|
|
|
app.add_latex_package('foo')
|
2014-09-28 07:10:26 -05:00
|
|
|
app.add_latex_package('bar', 'baz')
|
2014-09-26 22:47:27 -05:00
|
|
|
app.builder.build_all()
|
2014-09-28 07:00:51 -05:00
|
|
|
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
|
|
|
assert '\\usepackage{foo}' in result
|
2014-09-28 07:56:20 -05:00
|
|
|
assert '\\usepackage[baz]{bar}' in result
|
2015-08-20 22:59:54 -05:00
|
|
|
|
|
|
|
|
2016-01-15 20:29:31 -06:00
|
|
|
@with_app(buildername='latex', testroot='latex-babel')
|
|
|
|
def test_babel_with_no_language_settings(app, status, warning):
|
2015-08-20 22:59:54 -05:00
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-01-15 20:29:31 -06:00
|
|
|
assert '\\documentclass[letterpaper,10pt,english]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
|
|
|
assert '\\usepackage{times}' in result
|
|
|
|
assert '\\usepackage[Bjarne]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
2015-08-20 22:59:54 -05:00
|
|
|
in result)
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
|
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
|
2016-01-15 23:32:23 -06:00
|
|
|
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\shorthandoff' not in result
|
2015-08-20 22:59:54 -05:00
|
|
|
|
|
|
|
|
2016-01-15 20:29:31 -06:00
|
|
|
@with_app(buildername='latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'de'})
|
|
|
|
def test_babel_with_language_de(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,ngerman]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
|
|
|
assert '\\usepackage{times}' in result
|
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsngerman{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
|
|
|
|
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
|
2016-01-15 23:32:23 -06:00
|
|
|
assert '\\addto\\extrasngerman{\\def\\pageautorefname{page}}\n' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\shorthandoff{"}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'ru'})
|
|
|
|
def test_babel_with_language_ru(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,russian]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
|
|
|
assert '\\usepackage{times}' not in result
|
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsrussian{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\addto\\captionsrussian{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
|
|
|
|
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
|
2016-01-15 23:32:23 -06:00
|
|
|
assert '\\addto\\extrasrussian{\\def\\pageautorefname{page}}\n' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\shorthandoff' not in result
|
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'tr'})
|
|
|
|
def test_babel_with_language_tr(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,turkish]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
|
|
|
assert '\\usepackage{times}' in result
|
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsturkish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
|
|
|
|
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result
|
|
|
|
assert '\\shorthandoff{=}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='latex-babel',
|
2015-08-20 22:59:54 -05:00
|
|
|
confoverrides={'language': 'ja'})
|
2016-01-15 20:29:31 -06:00
|
|
|
def test_babel_with_language_ja(app, status, warning):
|
2015-08-20 22:59:54 -05:00
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-01-15 20:29:31 -06:00
|
|
|
assert '\\documentclass[letterpaper,10pt,dvipdfmx]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' not in result
|
|
|
|
assert '\\usepackage{times}' in result
|
|
|
|
assert '\\usepackage[Sonny]{fncychap}' not in result
|
|
|
|
assert '\\renewcommand{\\contentsname}{Table of content}\n' in result
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\renewcommand{\\figurename}{Fig.\\@ }\n' in result
|
|
|
|
assert '\\renewcommand{\\tablename}{Table.\\@ }\n' in result
|
2016-03-28 22:40:42 -05:00
|
|
|
assert u'\\def\\pageautorefname{ページ}\n' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\shorthandoff' not in result
|
2016-01-15 20:29:31 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'unknown'})
|
|
|
|
def test_babel_with_unknown_language(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,english]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
|
|
|
assert '\\usepackage{times}' in result
|
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
2016-05-27 22:57:46 -05:00
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
|
|
|
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
|
2016-01-15 23:32:23 -06:00
|
|
|
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\shorthandoff' not in result
|
2016-01-15 20:29:31 -06:00
|
|
|
|
|
|
|
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
2015-11-29 01:57:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex')
|
|
|
|
def test_footnote(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('\\begin{footnote}[1]\\sphinxAtStartFootnote\nnumbered\n%\n'
|
|
|
|
'\\end{footnote}') in result
|
|
|
|
assert ('\\begin{footnote}[2]\\sphinxAtStartFootnote\nauto numbered\n%\n'
|
|
|
|
'\\end{footnote}') in result
|
|
|
|
assert '\\begin{footnote}[3]\\sphinxAtStartFootnote\nnamed\n%\n\\end{footnote}' in result
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
assert '{\\hyperref[footnote:bar]{\\sphinxcrossref{{[}bar{]}}}}' in result
|
2015-11-29 01:57:25 -06:00
|
|
|
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} ' in result
|
|
|
|
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite' in result
|
|
|
|
assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite\n}' in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert '\\caption{Table caption \\sphinxfootnotemark[4]' in result
|
|
|
|
assert 'name \\sphinxfootnotemark[5]' in result
|
|
|
|
assert ('\\end{threeparttable}\n\n%\n'
|
|
|
|
'\\begin{footnotetext}[4]\sphinxAtStartFootnote\n'
|
|
|
|
'footnotes in table caption\n%\n\\end{footnotetext}%\n'
|
|
|
|
'\\begin{footnotetext}[5]\sphinxAtStartFootnote\n'
|
|
|
|
'footnotes in table\n%\n\\end{footnotetext}') in result
|
2015-12-02 19:33:15 -06:00
|
|
|
|
|
|
|
|
2015-12-06 20:02:45 -06:00
|
|
|
@with_app(buildername='latex', testroot='footnotes')
|
2016-10-15 05:09:58 -05:00
|
|
|
def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
|
2015-12-02 19:33:15 -06:00
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2015-12-02 20:39:25 -06:00
|
|
|
assert ('\\caption{This is the figure caption with a reference to \\label{index:id2}'
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}.}' in result)
|
2015-12-02 20:39:25 -06:00
|
|
|
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
|
|
|
|
assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result
|
2015-12-02 23:48:00 -06:00
|
|
|
assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[4]}\n'
|
2016-01-05 20:13:30 -06:00
|
|
|
'\\label{index:the-section-with-a-reference-to}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n'
|
|
|
|
'Footnote in section\n%\n\\end{footnotetext}') in result
|
2016-01-01 02:28:22 -06:00
|
|
|
assert ('\\caption{This is the figure caption with a footnote to '
|
2016-10-15 05:09:58 -05:00
|
|
|
'\\sphinxfootnotemark[6].}\label{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{index:id28}') in result
|
|
|
|
assert ('\\caption{footnote \\sphinxfootnotemark[8] '
|
|
|
|
'in caption \sphinxfootnotemark[9] of longtable}') in result
|
|
|
|
assert ('\end{longtable}\n\n%\n\\begin{footnotetext}[8]'
|
|
|
|
'\sphinxAtStartFootnote\n'
|
|
|
|
'Foot note in longtable\n%\n\\end{footnotetext}' in result)
|
|
|
|
assert ('This is a reference to the code-block in the footnote:\n'
|
|
|
|
'{\hyperref[index:codeblockinfootnote]{\\sphinxcrossref{\\DUrole'
|
|
|
|
'{std,std-ref}{I am in a footnote}}}}') in result
|
|
|
|
assert ('&\nThis is one more footnote with some code in it '
|
|
|
|
'\\sphinxfootnotemark[10].\n\\\\') in result
|
|
|
|
assert '\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]' in result
|
2015-12-06 20:02:45 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='footnotes',
|
|
|
|
confoverrides={'latex_show_urls': 'inline'})
|
|
|
|
def test_latex_show_urls_is_inline(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Same footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'footnote in bar\n%\n\\end{footnote} in bar.rst' in result)
|
|
|
|
assert ('Auto footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'footnote in baz\n%\n\\end{footnote} in baz.rst' in result)
|
|
|
|
assert ('\\phantomsection\\label{index:id30}{\\hyperref[index:the\\string-section'
|
2016-02-07 04:34:40 -06:00
|
|
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
'{\\sphinxcrossref{The section with a reference to '
|
|
|
|
'\\phantomsection\\label{index:id1}'
|
|
|
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('\\phantomsection\\label{index:id31}{\\hyperref[index:the\\string-section'
|
2016-02-25 07:07:18 -06:00
|
|
|
'\\string-with\\string-a\\string-reference\\string-to]'
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('First footnote: %\n\\begin{footnote}[2]\\sphinxAtStartFootnote\n'
|
|
|
|
'First\n%\n\\end{footnote}') in result
|
|
|
|
assert ('Second footnote: %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'Second\n%\n\\end{footnote}') in result
|
2015-12-06 20:02:45 -06:00
|
|
|
assert '\\href{http://sphinx-doc.org/}{Sphinx} (http://sphinx-doc.org/)' in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
|
|
|
'Third\n%\n\\end{footnote}') in result
|
2015-12-07 09:37:20 -06:00
|
|
|
assert ('\\href{http://sphinx-doc.org/~test/}{URL including tilde} '
|
|
|
|
'(http://sphinx-doc.org/\\textasciitilde{}test/)' in result)
|
2015-12-07 21:16:15 -06:00
|
|
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term} (http://sphinx-doc.org/)}] '
|
|
|
|
'\\leavevmode\nDescription' in result)
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('\\item[{Footnote in term \\sphinxfootnotemark[5]}] '
|
|
|
|
'\\leavevmode%\n\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n'
|
|
|
|
'Footnote in term\n%\n\\end{footnotetext}\nDescription' in result)
|
2015-12-18 23:42:01 -06:00
|
|
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist} '
|
|
|
|
'(http://sphinx-doc.org/)}] \\leavevmode\nDescription' in result)
|
2016-03-04 00:38:41 -06:00
|
|
|
assert ('\\url{https://github.com/sphinx-doc/sphinx}\n' in result)
|
2015-12-18 23:42:01 -06:00
|
|
|
assert ('\\href{mailto:sphinx-dev@googlegroups.com}'
|
|
|
|
'{sphinx-dev@googlegroups.com}' in result)
|
2015-12-06 20:02:45 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='footnotes',
|
|
|
|
confoverrides={'latex_show_urls': 'footnote'})
|
|
|
|
def test_latex_show_urls_is_footnote(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Same footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'footnote in bar\n%\n\\end{footnote} in bar.rst' in result)
|
|
|
|
assert ('Auto footnote number %\n\\begin{footnote}[2]\\sphinxAtStartFootnote\n'
|
|
|
|
'footnote in baz\n%\n\\end{footnote} in baz.rst' in result)
|
|
|
|
assert ('\\phantomsection\\label{index:id30}{\\hyperref[index:the\\string-section'
|
2016-02-07 04:34:40 -06:00
|
|
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
'{\\sphinxcrossref{The section with a reference '
|
|
|
|
'to \\phantomsection\\label{index:id1}'
|
|
|
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}' in result)
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('\\phantomsection\\label{index:id31}{\\hyperref[index:the\\string-section'
|
2016-03-02 07:58:17 -06:00
|
|
|
'\\string-with\\string-a\\string-reference\\string-to]'
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('First footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
|
|
|
'First\n%\n\\end{footnote}') in result
|
|
|
|
assert ('Second footnote: %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'Second\n%\n\\end{footnote}') in result
|
2015-12-06 20:02:45 -06:00
|
|
|
assert ('\\href{http://sphinx-doc.org/}{Sphinx}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'%\n\\begin{footnote}[4]\\sphinxAtStartFootnote\n'
|
|
|
|
'\\nolinkurl{http://sphinx-doc.org/}\n%\n\\end{footnote}') in result
|
|
|
|
assert ('Third footnote: %\n\\begin{footnote}[6]\\sphinxAtStartFootnote\n'
|
|
|
|
'Third\n%\n\\end{footnote}') in result
|
2015-12-07 09:37:20 -06:00
|
|
|
assert ('\\href{http://sphinx-doc.org/~test/}{URL including tilde}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'%\n\\begin{footnote}[5]\\sphinxAtStartFootnote\n'
|
|
|
|
'\\nolinkurl{http://sphinx-doc.org/~test/}\n%\n\\end{footnote}') in result
|
|
|
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}\\sphinxfootnotemark[8]}] '
|
|
|
|
'\\leavevmode%\n\\begin{footnotetext}[8]\\sphinxAtStartFootnote\n'
|
|
|
|
'\\nolinkurl{http://sphinx-doc.org/}\n%\n'
|
|
|
|
'\\end{footnotetext}\nDescription') in result
|
|
|
|
assert ('\\item[{Footnote in term \\sphinxfootnotemark[10]}] '
|
|
|
|
'\\leavevmode%\n\\begin{footnotetext}[10]\\sphinxAtStartFootnote\n'
|
|
|
|
'Footnote in term\n%\n\\end{footnotetext}\nDescription') in result
|
|
|
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}'
|
|
|
|
'\\sphinxfootnotemark[9]}] '
|
|
|
|
'\\leavevmode%\n\\begin{footnotetext}[9]\\sphinxAtStartFootnote\n'
|
|
|
|
'\\nolinkurl{http://sphinx-doc.org/}\n%\n'
|
|
|
|
'\\end{footnotetext}\nDescription') in result
|
2016-03-04 00:38:41 -06:00
|
|
|
assert ('\\url{https://github.com/sphinx-doc/sphinx}\n' in result)
|
2015-12-18 23:42:01 -06:00
|
|
|
assert ('\\href{mailto:sphinx-dev@googlegroups.com}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'{sphinx-dev@googlegroups.com}\n') in result
|
2015-12-06 20:02:45 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='footnotes',
|
|
|
|
confoverrides={'latex_show_urls': 'no'})
|
|
|
|
def test_latex_show_urls_is_no(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Same footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
|
|
|
assert ('Auto footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'footnote in baz\n%\n\\end{footnote} in baz.rst') in result
|
|
|
|
assert ('\\phantomsection\\label{index:id30}{\\hyperref[index:the\\string-section'
|
2016-02-07 04:34:40 -06:00
|
|
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
'{\\sphinxcrossref{The section with a reference '
|
|
|
|
'to \\phantomsection\\label{index:id1}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'{\\hyperref[index:authoryear]{\\sphinxcrossref{{[}AuthorYear{]}}}}}}}') in result
|
|
|
|
assert ('\\phantomsection\\label{index:id31}{\\hyperref[index:the\\string-section'
|
2016-03-02 07:58:17 -06:00
|
|
|
'\\string-with\\string-a\\string-reference\\string-to]'
|
Fix #2629. Add new config option ``latex_keep_old_macro_names``
The cause of the issue was a clash about ``\titleref`` macro being already
defined in memoir class context. To avoid similar problems, this makes
the text styling macros
``\strong``, ``\code``, ``\bfcode``, ``\email``, ``\tablecontinued``,
``\titleref``, ``\menuselection``, ``\accelerator``, ``\crossref``,
``\termref``, ``\optional``,
also available with ``\sphinx`` prefix, with a conf.py boolean option to
let sphinx.sty only define ``\sphinx``-prefixed macros. As default value
is False, backwards compatibility is maintained.
On this occasion, some internal non-public macros have been renamed with
prefix ``\spx@``. The command
find . -name '*.sty' -exec grep -l \\\\spx@ {} \;
has been executed in TeXLive 2015 and 2016 installations to check no
package defines macros starting with ``\spx@``.
Some internal macros having public names (because they are written by
latex.py into the body of the latex document) have been renamed to have
``\sphinx`` prefix. The macros in sphinx.sty starting with \py@, or \DU,
or \PYG have not been modified. Similarly ``\release``, ``\version``,
``\releasename``, etc... have not been renamed.
2016-06-12 12:35:47 -05:00
|
|
|
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('First footnote: %\n\\begin{footnote}[2]\\sphinxAtStartFootnote\n'
|
|
|
|
'First\n%\n\\end{footnote}') in result
|
|
|
|
assert ('Second footnote: %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'Second\n%\n\\end{footnote}') in result
|
2015-12-06 20:02:45 -06:00
|
|
|
assert '\\href{http://sphinx-doc.org/}{Sphinx}' in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
|
|
|
'Third\n%\n\\end{footnote}') in result
|
2015-12-07 09:37:20 -06:00
|
|
|
assert '\\href{http://sphinx-doc.org/~test/}{URL including tilde}' in result
|
2015-12-07 21:16:15 -06:00
|
|
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}}] '
|
2016-10-15 05:09:58 -05:00
|
|
|
'\\leavevmode\nDescription') in result
|
|
|
|
assert ('\\item[{Footnote in term \\sphinxfootnotemark[5]}] '
|
|
|
|
'\\leavevmode%\n\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n'
|
|
|
|
'Footnote in term\n%\n\\end{footnotetext}\nDescription') in result
|
2015-12-07 21:16:15 -06:00
|
|
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}}] '
|
2016-10-15 05:09:58 -05:00
|
|
|
'\\leavevmode\nDescription') in result
|
2016-03-04 00:38:41 -06:00
|
|
|
assert ('\\url{https://github.com/sphinx-doc/sphinx}\n' in result)
|
2015-12-18 23:42:01 -06:00
|
|
|
assert ('\\href{mailto:sphinx-dev@googlegroups.com}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'{sphinx-dev@googlegroups.com}\n') in result
|
2016-01-05 01:48:22 -06:00
|
|
|
|
|
|
|
|
2015-09-16 05:08:12 -05:00
|
|
|
@with_app(buildername='latex', testroot='image-in-section')
|
|
|
|
def test_image_in_section(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-07-02 10:58:27 -05:00
|
|
|
assert ('\\chapter[Test section]{\\lowercase{\\sphinxincludegraphics'
|
2016-07-07 11:09:28 -05:00
|
|
|
'[width=15bp,height=15bp]}{{pic}.png} Test section}'
|
2015-09-16 05:08:12 -05:00
|
|
|
in result)
|
2016-06-13 03:30:48 -05:00
|
|
|
assert ('\\chapter[Other {[}blah{]} section]{Other {[}blah{]} '
|
2016-07-07 11:09:28 -05:00
|
|
|
'\\lowercase{\\sphinxincludegraphics[width=15bp,height=15bp]}'
|
2016-07-02 10:58:27 -05:00
|
|
|
'{{pic}.png} section}' in result)
|
2016-06-13 03:30:48 -05:00
|
|
|
assert ('\\chapter{Another section}' in result)
|
2015-09-16 05:08:12 -05:00
|
|
|
|
|
|
|
|
2016-01-05 01:48:22 -06:00
|
|
|
@with_app(buildername='latex', confoverrides={'latex_logo': 'notfound.jpg'})
|
|
|
|
def test_latex_logo_if_not_found(app, status, warning):
|
|
|
|
try:
|
|
|
|
app.builder.build_all()
|
|
|
|
assert False # SphinxError not raised
|
|
|
|
except Exception as exc:
|
|
|
|
assert isinstance(exc, SphinxError)
|
2016-01-05 10:34:29 -06:00
|
|
|
|
|
|
|
|
2016-01-05 18:51:34 -06:00
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
2016-01-05 10:34:29 -06:00
|
|
|
confoverrides={'latex_documents': [
|
|
|
|
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
|
|
|
|
'Georg Brandl', 'manual'),
|
|
|
|
]})
|
|
|
|
def test_toctree_maxdepth_manual(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\setcounter{tocdepth}{1}' in result
|
2016-05-26 09:23:07 -05:00
|
|
|
assert '\\setcounter{secnumdepth}' not in result
|
2016-01-05 10:34:29 -06:00
|
|
|
|
|
|
|
|
2016-01-05 18:51:34 -06:00
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
2016-01-05 10:34:29 -06:00
|
|
|
confoverrides={'latex_documents': [
|
|
|
|
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
|
|
|
|
'Georg Brandl', 'howto'),
|
|
|
|
]})
|
|
|
|
def test_toctree_maxdepth_howto(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\setcounter{tocdepth}{2}' in result
|
2016-05-26 09:23:07 -05:00
|
|
|
assert '\\setcounter{secnumdepth}' not in result
|
2016-01-20 20:32:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'master_doc': 'foo'})
|
|
|
|
def test_toctree_not_found(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\setcounter{tocdepth}' not in result
|
2016-05-26 09:23:07 -05:00
|
|
|
assert '\\setcounter{secnumdepth}' not in result
|
2016-01-20 20:32:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'master_doc': 'bar'})
|
|
|
|
def test_toctree_without_maxdepth(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\setcounter{tocdepth}' not in result
|
2016-05-26 09:23:07 -05:00
|
|
|
assert '\\setcounter{secnumdepth}' not in result
|
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'master_doc': 'qux'})
|
|
|
|
def test_toctree_with_deeper_maxdepth(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\setcounter{tocdepth}{3}' in result
|
|
|
|
assert '\\setcounter{secnumdepth}{3}' in result
|
2016-02-23 10:30:17 -06:00
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': None})
|
|
|
|
def test_latex_toplevel_sectioning_is_None(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\chapter{Foo}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'part'})
|
|
|
|
def test_latex_toplevel_sectioning_is_part(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\part{Foo}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'chapter'})
|
|
|
|
def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\chapter{Foo}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'section'})
|
|
|
|
def test_latex_toplevel_sectioning_is_section(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\section{Foo}' in result
|