2010-01-17 05:29:00 -06:00
|
|
|
"""Test the build process with LaTeX builder with the test root."""
|
|
|
|
|
|
|
|
import os
|
2010-06-03 10:25:16 -05:00
|
|
|
import re
|
2019-01-12 05:14:26 -06:00
|
|
|
import subprocess
|
2016-07-13 07:15:16 -05:00
|
|
|
from itertools import product
|
2023-01-07 11:35:21 -06:00
|
|
|
from pathlib import Path
|
2017-02-25 17:13:06 -06:00
|
|
|
from shutil import copyfile
|
2022-10-17 09:54:59 -05:00
|
|
|
from subprocess import CalledProcessError
|
2010-01-17 05:29:00 -06:00
|
|
|
|
2017-01-03 07:24:00 -06:00
|
|
|
import pytest
|
2014-04-28 21:46:47 -05:00
|
|
|
|
2018-09-03 07:18:58 -05:00
|
|
|
from sphinx.builders.latex import default_latex_documents
|
|
|
|
from sphinx.config import Config
|
2020-11-15 02:03:26 -06:00
|
|
|
from sphinx.errors import SphinxError
|
2023-03-31 09:42:58 -05:00
|
|
|
from sphinx.ext.intersphinx import load_mappings, normalize_intersphinx_mapping
|
|
|
|
from sphinx.ext.intersphinx import setup as intersphinx_setup
|
2018-09-07 20:52:24 -05:00
|
|
|
from sphinx.testing.util import strip_escseq
|
2023-03-05 09:25:47 -06:00
|
|
|
from sphinx.util.osutil import ensuredir
|
2010-01-17 05:29:00 -06:00
|
|
|
from sphinx.writers.latex import LaTeXTranslator
|
|
|
|
|
2020-11-20 12:04:26 -06:00
|
|
|
from .test_build_html import ENV_WARNINGS
|
|
|
|
|
2023-03-05 09:25:47 -06:00
|
|
|
try:
|
|
|
|
from contextlib import chdir
|
|
|
|
except ImportError:
|
|
|
|
from sphinx.util.osutil import _chdir as chdir
|
|
|
|
|
2016-07-13 07:15:16 -05:00
|
|
|
LATEX_ENGINES = ['pdflatex', 'lualatex', 'xelatex']
|
|
|
|
DOCCLASSES = ['howto', 'manual']
|
2016-10-27 04:43:20 -05:00
|
|
|
STYLEFILES = ['article.cls', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty',
|
2017-05-01 09:22:04 -05:00
|
|
|
'framed.sty', 'color.sty', 'fancyvrb.sty',
|
2022-10-12 10:15:40 -05:00
|
|
|
'fncychap.sty', 'geometry.sty', 'kvoptions.sty', 'hyperref.sty',
|
|
|
|
'booktabs.sty']
|
2016-07-13 07:15:16 -05:00
|
|
|
|
2010-01-17 05:29:00 -06:00
|
|
|
LATEX_WARNINGS = ENV_WARNINGS + """\
|
2022-06-16 15:07:25 -05:00
|
|
|
%(root)s/index.rst:\\d+: WARNING: unknown option: '&option'
|
2016-07-14 09:12:57 -05:00
|
|
|
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
|
2018-03-17 00:37:50 -05:00
|
|
|
%(root)s/index.rst:\\d+: WARNING: a suitable image for latex builder not found: foo.\\*
|
2023-03-17 10:32:27 -05:00
|
|
|
%(root)s/index.rst:\\d+: WARNING: Could not lex literal_block .* as "c". Highlighting skipped.
|
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:
|
2022-10-17 09:54:59 -05:00
|
|
|
subprocess.run(['kpsewhich'] + list(filenames), capture_output=True, check=True)
|
2016-07-13 07:15:16 -05:00
|
|
|
return True
|
2019-01-12 05:14:26 -06:00
|
|
|
except (OSError, CalledProcessError):
|
|
|
|
return False # command not found or exit with non-zero
|
2016-07-13 07:15:16 -05:00
|
|
|
|
|
|
|
|
2016-11-03 22:06:19 -05:00
|
|
|
# compile latex document with app.config.latex_engine
|
2018-09-03 07:18:58 -05:00
|
|
|
def compile_latex_document(app, filename='python.tex'):
|
2016-11-03 22:06:19 -05:00
|
|
|
# now, try to run latex over it
|
2019-01-12 05:14:26 -06:00
|
|
|
try:
|
2023-03-05 09:25:47 -06:00
|
|
|
with chdir(app.outdir):
|
2019-02-03 08:54:22 -06:00
|
|
|
ensuredir(app.config.latex_engine)
|
|
|
|
# keep a copy of latex file for this engine in case test fails
|
|
|
|
copyfile(filename, app.config.latex_engine + '/' + filename)
|
|
|
|
args = [app.config.latex_engine,
|
|
|
|
'--halt-on-error',
|
|
|
|
'--interaction=nonstopmode',
|
|
|
|
'-output-directory=%s' % app.config.latex_engine,
|
|
|
|
filename]
|
2022-10-17 09:54:59 -05:00
|
|
|
subprocess.run(args, capture_output=True, check=True)
|
2020-06-13 16:46:19 -05:00
|
|
|
except OSError as exc: # most likely the latex executable was not found
|
|
|
|
raise pytest.skip.Exception from exc
|
2019-01-12 05:14:26 -06:00
|
|
|
except CalledProcessError as exc:
|
2022-10-13 11:37:07 -05:00
|
|
|
print(exc.stdout.decode('utf8'))
|
|
|
|
print(exc.stderr.decode('utf8'))
|
2023-01-01 18:01:14 -06:00
|
|
|
raise AssertionError(f'{app.config.latex_engine} exited with '
|
|
|
|
f'return code {exc.returncode}')
|
2016-11-03 22:06:19 -05:00
|
|
|
|
|
|
|
|
2017-04-22 04:14:06 -05:00
|
|
|
def skip_if_requested(testfunc):
|
|
|
|
if 'SKIP_LATEX_BUILD' in os.environ:
|
|
|
|
msg = 'Skip LaTeX builds because SKIP_LATEX_BUILD is set'
|
2017-04-27 09:38:42 -05:00
|
|
|
return pytest.mark.skipif(True, reason=msg)(testfunc)
|
2017-04-22 04:14:06 -05:00
|
|
|
else:
|
|
|
|
return testfunc
|
|
|
|
|
|
|
|
|
2016-11-04 01:14:41 -05:00
|
|
|
def skip_if_stylefiles_notfound(testfunc):
|
2016-07-13 07:15:16 -05:00
|
|
|
if kpsetest(*STYLEFILES) is False:
|
2016-12-24 03:43:35 -06:00
|
|
|
msg = 'not running latex, the required styles do not seem to be installed'
|
2017-04-27 09:38:42 -05:00
|
|
|
return pytest.mark.skipif(True, reason=msg)(testfunc)
|
2016-11-04 01:14:41 -05:00
|
|
|
else:
|
|
|
|
return testfunc
|
2016-07-13 07:15:16 -05:00
|
|
|
|
2016-11-04 01:14:41 -05:00
|
|
|
|
2017-04-22 04:14:06 -05:00
|
|
|
@skip_if_requested
|
2016-11-04 01:14:41 -05:00
|
|
|
@skip_if_stylefiles_notfound
|
2017-01-03 07:24:00 -06:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"engine,docclass",
|
|
|
|
product(LATEX_ENGINES, DOCCLASSES),
|
|
|
|
)
|
|
|
|
@pytest.mark.sphinx('latex')
|
|
|
|
def test_build_latex_doc(app, status, warning, engine, docclass):
|
2023-03-31 09:42:58 -05:00
|
|
|
app.config.intersphinx_mapping = {
|
|
|
|
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
|
|
|
|
}
|
|
|
|
intersphinx_setup(app)
|
2016-07-13 07:15:16 -05:00
|
|
|
app.config.latex_engine = engine
|
2019-08-20 10:06:06 -05:00
|
|
|
app.config.latex_documents = [app.config.latex_documents[0][:4] + (docclass,)]
|
2022-10-12 10:15:40 -05:00
|
|
|
if engine == 'xelatex':
|
|
|
|
app.config.latex_table_style = ['booktabs']
|
|
|
|
elif engine == 'lualatex':
|
|
|
|
app.config.latex_table_style = ['colorrows']
|
2023-03-31 09:42:58 -05:00
|
|
|
normalize_intersphinx_mapping(app, app.config)
|
|
|
|
load_mappings(app)
|
2019-12-26 09:14:24 -06:00
|
|
|
app.builder.init()
|
2016-07-13 07:15:16 -05:00
|
|
|
|
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()
|
|
|
|
|
2018-09-03 07:18:58 -05:00
|
|
|
compile_latex_document(app, 'sphinxtests.tex')
|
2014-09-26 22:47:27 -05:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex')
|
2016-05-03 07:31:43 -05:00
|
|
|
def test_writer(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
2016-05-03 07:31:43 -05:00
|
|
|
|
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'
|
2018-01-20 02:06:56 -06:00
|
|
|
'\\sphinxfigcaption{figure in table}\\label{\\detokenize{markup:id8}}'
|
2016-06-19 04:02:39 -05:00
|
|
|
'\\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'
|
2018-01-20 02:06:56 -06:00
|
|
|
'\\caption{figure with align option}\\label{\\detokenize{markup:id9}}'
|
2023-01-08 12:40:24 -06:00
|
|
|
'\\end{wrapfigure}\n\n'
|
|
|
|
'\\mbox{}\\par\\vskip-\\dimexpr\\baselineskip+\\parskip\\relax' 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'
|
2016-12-08 14:43:04 -06:00
|
|
|
'\\caption{figure with align \\& figwidth option}'
|
2018-01-20 02:06:56 -06:00
|
|
|
'\\label{\\detokenize{markup:id10}}'
|
2023-01-08 12:40:24 -06:00
|
|
|
'\\end{wrapfigure}\n\n'
|
|
|
|
'\\mbox{}\\par\\vskip-\\dimexpr\\baselineskip+\\parskip\\relax' 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'
|
2016-12-08 14:43:04 -06:00
|
|
|
'\\caption{figure with align \\& width option}'
|
2018-01-20 02:06:56 -06:00
|
|
|
'\\label{\\detokenize{markup:id11}}'
|
2023-01-08 12:40:24 -06:00
|
|
|
'\\end{wrapfigure}\n\n'
|
|
|
|
'\\mbox{}\\par\\vskip-\\dimexpr\\baselineskip+\\parskip\\relax' in result)
|
2016-05-03 07:31:43 -05:00
|
|
|
|
2018-12-08 09:35:46 -06:00
|
|
|
assert 'Footnotes' not in result
|
|
|
|
|
2023-03-26 11:52:06 -05:00
|
|
|
assert ('\\begin{sphinxseealso}{See also:}\n\n'
|
2023-01-03 10:11:58 -06:00
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'something, something else, something more\n'
|
|
|
|
'\\begin{description}\n'
|
|
|
|
'\\sphinxlineitem{\\sphinxhref{http://www.google.com}{Google}}\n'
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'For everything.\n'
|
|
|
|
'\n'
|
|
|
|
'\\end{description}\n'
|
|
|
|
'\n\n\\end{sphinxseealso}\n\n' in result)
|
|
|
|
|
2016-05-03 07:31:43 -05:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='warnings', freshenv=True)
|
2016-07-14 09:12:57 -05:00
|
|
|
def test_latex_warnings(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2017-05-01 16:19:53 -05:00
|
|
|
warnings = strip_escseq(re.sub(re.escape(os.sep) + '{1,2}', '/', warning.getvalue()))
|
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), \
|
2023-02-17 19:19:49 -06:00
|
|
|
"Warnings don't match:\n" + \
|
2016-07-14 09:12:57 -05:00
|
|
|
'--- Expected (regex):\n' + warnings_exp + \
|
|
|
|
'--- Got:\n' + warnings
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic')
|
2018-01-10 06:35:21 -06:00
|
|
|
def test_latex_basic(app, status, warning):
|
2016-11-22 09:42:15 -06:00
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
2016-11-22 09:42:15 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2018-01-10 06:35:21 -06:00
|
|
|
assert r'\title{The basic Sphinx documentation for testing}' in result
|
|
|
|
assert r'\release{}' in result
|
|
|
|
assert r'\renewcommand{\releasename}{}' in result
|
2016-11-22 09:42:15 -06:00
|
|
|
|
|
|
|
|
2019-12-21 02:39:25 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic',
|
|
|
|
confoverrides={
|
2023-02-17 16:11:14 -06:00
|
|
|
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
2019-12-21 02:39:25 -06:00
|
|
|
})
|
|
|
|
def test_latex_basic_manual(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
assert r'\def\sphinxdocclass{report}' in result
|
|
|
|
assert r'\documentclass[letterpaper,10pt,english]{sphinxmanual}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='basic',
|
|
|
|
confoverrides={
|
2023-02-17 16:11:14 -06:00
|
|
|
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
2019-12-21 02:39:25 -06:00
|
|
|
})
|
|
|
|
def test_latex_basic_howto(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
assert r'\def\sphinxdocclass{article}' in result
|
|
|
|
assert r'\documentclass[letterpaper,10pt,english]{sphinxhowto}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='basic',
|
|
|
|
confoverrides={
|
|
|
|
'language': 'ja',
|
2023-02-17 16:11:14 -06:00
|
|
|
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
2019-12-21 02:39:25 -06:00
|
|
|
})
|
|
|
|
def test_latex_basic_manual_ja(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
|
|
|
print(result)
|
2020-11-28 23:49:44 -06:00
|
|
|
assert r'\def\sphinxdocclass{ujbook}' in result
|
2019-12-21 02:39:25 -06:00
|
|
|
assert r'\documentclass[letterpaper,10pt,dvipdfmx]{sphinxmanual}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='basic',
|
|
|
|
confoverrides={
|
|
|
|
'language': 'ja',
|
2023-02-17 16:11:14 -06:00
|
|
|
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
2019-12-21 02:39:25 -06:00
|
|
|
})
|
|
|
|
def test_latex_basic_howto_ja(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
|
|
|
print(result)
|
2020-11-28 23:49:44 -06:00
|
|
|
assert r'\def\sphinxdocclass{ujreport}' in result
|
2019-12-21 02:39:25 -06:00
|
|
|
assert r'\documentclass[letterpaper,10pt,dvipdfmx]{sphinxhowto}' in result
|
|
|
|
|
|
|
|
|
2019-12-28 04:36:55 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-theme')
|
|
|
|
def test_latex_theme(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
assert r'\def\sphinxdocclass{book}' in result
|
2020-04-03 23:28:29 -05:00
|
|
|
assert r'\documentclass[a4paper,12pt,english]{sphinxbook}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-theme',
|
|
|
|
confoverrides={'latex_elements': {'papersize': 'b5paper',
|
|
|
|
'pointsize': '9pt'}})
|
|
|
|
def test_latex_theme_papersize(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
assert r'\def\sphinxdocclass{book}' in result
|
2020-03-31 09:22:25 -05:00
|
|
|
assert r'\documentclass[b5paper,9pt,english]{sphinxbook}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-theme',
|
|
|
|
confoverrides={'latex_theme_options': {'papersize': 'b5paper',
|
|
|
|
'pointsize': '9pt'}})
|
|
|
|
def test_latex_theme_options(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
|
|
|
print(result)
|
|
|
|
assert r'\def\sphinxdocclass{book}' in result
|
2020-04-03 23:28:29 -05:00
|
|
|
assert r'\documentclass[b5paper,9pt,english]{sphinxbook}' in result
|
2019-12-28 04:36:55 -06:00
|
|
|
|
|
|
|
|
2019-05-25 12:47:33 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic', confoverrides={'language': 'zh'})
|
|
|
|
def test_latex_additional_settings_for_language_code(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
2019-05-25 12:47:33 -05:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert r'\usepackage{xeCJK}' in result
|
|
|
|
|
|
|
|
|
2019-09-30 04:52:34 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic', confoverrides={'language': 'el'})
|
|
|
|
def test_latex_additional_settings_for_greek(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
2019-09-30 04:52:34 -05:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\usepackage{polyglossia}\n\\setmainlanguage{greek}' in result
|
|
|
|
assert '\\newfontfamily\\greekfonttt{FreeMono}' in result
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-title')
|
2016-11-22 09:42:15 -06:00
|
|
|
def test_latex_title_after_admonitions(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
2016-11-22 09:42:15 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2019-12-05 11:19:38 -06:00
|
|
|
assert '\\title{test\\sphinxhyphen{}latex\\sphinxhyphen{}title}' in result
|
2016-11-22 09:42:15 -06:00
|
|
|
|
|
|
|
|
2018-01-10 06:35:21 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic',
|
2021-03-15 11:33:27 -05:00
|
|
|
confoverrides={'release': '1.0_0'})
|
2018-01-10 06:35:21 -06:00
|
|
|
def test_latex_release(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
2018-01-10 06:35:21 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2021-03-15 11:33:27 -05:00
|
|
|
assert r'\release{1.0\_0}' in result
|
2018-01-10 06:35:21 -06:00
|
|
|
assert r'\renewcommand{\releasename}{Release}' in result
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='numfig',
|
2017-01-25 10:13:17 -06:00
|
|
|
confoverrides={'numfig': True})
|
2014-10-01 21:17:34 -05:00
|
|
|
def test_numref(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2014-10-01 21:17:34 -05:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
|
|
|
'{Fig.\\@ \\ref{\\detokenize{index:fig1}}}') in result
|
2016-12-08 15:30:48 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
|
|
|
'{Figure\\ref{\\detokenize{baz:fig22}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:table-1}]'
|
|
|
|
'{Table \\ref{\\detokenize{index:table-1}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{baz:table22}]'
|
|
|
|
'{Table:\\ref{\\detokenize{baz:table22}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{index:code-1}]'
|
|
|
|
'{Listing \\ref{\\detokenize{index:code-1}}}') in result
|
2016-12-08 15:30:48 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{baz:code22}]'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{Code\\sphinxhyphen{}\\ref{\\detokenize{baz:code22}}}') in result
|
2016-12-08 15:30:48 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]'
|
|
|
|
'{Section \\ref{\\detokenize{foo:foo}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{bar:bar-a}]'
|
|
|
|
'{Section \\ref{\\detokenize{bar:bar-a}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]{Fig.\\ref{\\detokenize{index:fig1}} '
|
|
|
|
'\\nameref{\\detokenize{index:fig1}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]{Sect.\\ref{\\detokenize{foo:foo}} '
|
|
|
|
'\\nameref{\\detokenize{foo:foo}}}') in result
|
2015-02-22 09:29:05 -06:00
|
|
|
|
2018-11-24 03:37:28 -06:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-11-24 03:37:28 -06:00
|
|
|
print(result)
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table }}' in result
|
2018-11-24 03:57:13 -06:00
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Listing}}' in result
|
2018-11-24 03:37:28 -06:00
|
|
|
|
2015-02-22 09:29:05 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='numfig',
|
|
|
|
confoverrides={'numfig': True,
|
|
|
|
'numfig_format': {'figure': 'Figure:%s',
|
|
|
|
'table': 'Tab_%s',
|
|
|
|
'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()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-02-22 09:29:05 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-12-08 14:43:04 -06:00
|
|
|
assert '\\ref{\\detokenize{index:fig1}}' in result
|
|
|
|
assert '\\ref{\\detokenize{baz:fig22}}' in result
|
|
|
|
assert '\\ref{\\detokenize{index:table-1}}' in result
|
|
|
|
assert '\\ref{\\detokenize{baz:table22}}' in result
|
|
|
|
assert '\\ref{\\detokenize{index:code-1}}' in result
|
|
|
|
assert '\\ref{\\detokenize{baz:code22}}' in result
|
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
|
|
|
'{Figure:\\ref{\\detokenize{index:fig1}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
|
|
|
'{Figure\\ref{\\detokenize{baz:fig22}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{index:table-1}]'
|
|
|
|
'{Tab\\_\\ref{\\detokenize{index:table-1}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{baz:table22}]'
|
|
|
|
'{Table:\\ref{\\detokenize{baz:table22}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{index:code-1}]'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{Code\\sphinxhyphen{}\\ref{\\detokenize{index:code-1}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{baz:code22}]'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{Code\\sphinxhyphen{}\\ref{\\detokenize{baz:code22}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{SECTION\\sphinxhyphen{}\\ref{\\detokenize{foo:foo}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{bar:bar-a}]'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{SECTION\\sphinxhyphen{}\\ref{\\detokenize{bar:bar-a}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]{Fig.\\ref{\\detokenize{index:fig1}} '
|
|
|
|
'\\nameref{\\detokenize{index:fig1}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]{Sect.\\ref{\\detokenize{foo:foo}} '
|
|
|
|
'\\nameref{\\detokenize{foo:foo}}}') in result
|
2015-02-22 09:29:05 -06:00
|
|
|
|
2018-11-24 03:37:28 -06:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-11-24 03:37:28 -06:00
|
|
|
print(result)
|
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab\_}}' in result
|
2018-11-24 03:57:13 -06:00
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Code-}}' in result
|
2018-11-24 03:37:28 -06:00
|
|
|
|
2015-02-22 09:29:05 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='numfig',
|
|
|
|
confoverrides={'numfig': True,
|
|
|
|
'numfig_format': {'figure': 'Figure:%s.',
|
|
|
|
'table': 'Tab_%s:',
|
|
|
|
'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()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-02-22 09:29:05 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
|
|
|
'{Figure:\\ref{\\detokenize{index:fig1}}.\\@}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
|
|
|
'{Figure\\ref{\\detokenize{baz:fig22}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{index:table-1}]'
|
|
|
|
'{Tab\\_\\ref{\\detokenize{index:table-1}}:}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{baz:table22}]'
|
|
|
|
'{Table:\\ref{\\detokenize{baz:table22}}}') in result
|
2019-12-05 11:19:38 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:code-1}]{Code\\sphinxhyphen{}\\ref{\\detokenize{index:code-1}} '
|
2019-11-17 18:10:57 -06:00
|
|
|
'| }') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{baz:code22}]'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{Code\\sphinxhyphen{}\\ref{\\detokenize{baz:code22}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]'
|
|
|
|
'{SECTION\\_\\ref{\\detokenize{foo:foo}}\\_}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{bar:bar-a}]'
|
|
|
|
'{SECTION\\_\\ref{\\detokenize{bar:bar-a}}\\_}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]{Fig.\\ref{\\detokenize{index:fig1}} '
|
|
|
|
'\\nameref{\\detokenize{index:fig1}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]{Sect.\\ref{\\detokenize{foo:foo}} '
|
|
|
|
'\\nameref{\\detokenize{foo:foo}}}') in result
|
2014-10-01 21:17:34 -05:00
|
|
|
|
2018-11-24 03:37:28 -06:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-11-24 03:37:28 -06:00
|
|
|
print(result)
|
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\def\fnum@figure{\figurename\thefigure{}.}' in result
|
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab\_}}' in result
|
|
|
|
assert r'\def\fnum@table{\tablename\thetable{}:}' in result
|
2018-11-24 03:57:13 -06:00
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Code-}}' in result
|
2018-11-24 03:37:28 -06:00
|
|
|
|
2014-10-01 21:17:34 -05:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='numfig',
|
|
|
|
confoverrides={'numfig': True, 'language': 'ja'})
|
2015-03-07 17:30:09 -06:00
|
|
|
def test_numref_with_language_ja(app, status, warning):
|
2023-01-03 22:22:20 -06:00
|
|
|
app.build()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-03-07 17:30:09 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2018-12-15 08:02:28 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
|
|
|
'{\u56f3 \\ref{\\detokenize{index:fig1}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
|
|
|
'{Figure\\ref{\\detokenize{baz:fig22}}}') in result
|
2018-12-15 08:02:28 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:table-1}]'
|
|
|
|
'{\u8868 \\ref{\\detokenize{index:table-1}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{baz:table22}]'
|
|
|
|
'{Table:\\ref{\\detokenize{baz:table22}}}') in result
|
2018-12-15 08:02:28 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:code-1}]'
|
|
|
|
'{\u30ea\u30b9\u30c8 \\ref{\\detokenize{index:code-1}}}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{baz:code22}]'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{Code\\sphinxhyphen{}\\ref{\\detokenize{baz:code22}}}') in result
|
2018-12-15 08:02:28 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]'
|
|
|
|
'{\\ref{\\detokenize{foo:foo}} \u7ae0}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{bar:bar-a}]'
|
|
|
|
'{\\ref{\\detokenize{bar:bar-a}} \u7ae0}') in result
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\hyperref[\\detokenize{index:fig1}]{Fig.\\ref{\\detokenize{index:fig1}} '
|
|
|
|
'\\nameref{\\detokenize{index:fig1}}}') in result
|
|
|
|
assert ('\\hyperref[\\detokenize{foo:foo}]{Sect.\\ref{\\detokenize{foo:foo}} '
|
|
|
|
'\\nameref{\\detokenize{foo:foo}}}') in result
|
2015-03-07 17:30:09 -06:00
|
|
|
|
2018-11-24 03:37:28 -06:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-11-24 03:37:28 -06:00
|
|
|
print(result)
|
2019-01-05 07:42:20 -06:00
|
|
|
assert '\\@iden{\\renewcommand{\\figurename}{図 }}' in result
|
|
|
|
assert '\\@iden{\\renewcommand{\\tablename}{表 }}' in result
|
|
|
|
assert '\\@iden{\\renewcommand{\\literalblockname}{リスト}}' in result
|
2018-11-24 03:37:28 -06:00
|
|
|
|
2015-03-07 17:30:09 -06:00
|
|
|
|
2017-12-18 06:02:09 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-numfig')
|
|
|
|
def test_latex_obey_numfig_is_false(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
2017-12-18 06:02:09 -06:00
|
|
|
assert '\\usepackage{sphinx}' in result
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
2017-12-18 06:02:09 -06:00
|
|
|
assert '\\usepackage{sphinx}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-numfig',
|
|
|
|
confoverrides={'numfig': True, 'numfig_secnum_depth': 0})
|
|
|
|
def test_latex_obey_numfig_secnum_depth_is_zero(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
2017-12-21 05:23:20 -06:00
|
|
|
assert '\\usepackage[,nonumfigreset,mathnumfig]{sphinx}' in result
|
2017-12-18 06:02:09 -06:00
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
2017-12-21 05:23:20 -06:00
|
|
|
assert '\\usepackage[,nonumfigreset,mathnumfig]{sphinx}' in result
|
2017-12-18 06:02:09 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-numfig',
|
|
|
|
confoverrides={'numfig': True, 'numfig_secnum_depth': 2})
|
|
|
|
def test_latex_obey_numfig_secnum_depth_is_two(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
2017-12-21 05:23:20 -06:00
|
|
|
assert '\\usepackage[,numfigreset=2,mathnumfig]{sphinx}' in result
|
2017-12-18 06:02:09 -06:00
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
2017-12-21 05:23:20 -06:00
|
|
|
assert '\\usepackage[,numfigreset=3,mathnumfig]{sphinx}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-numfig',
|
|
|
|
confoverrides={'numfig': True, 'math_numfig': False})
|
|
|
|
def test_latex_obey_numfig_but_math_numfig_false(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
2017-12-21 05:23:20 -06:00
|
|
|
assert '\\usepackage[,numfigreset=1]{sphinx}' in result
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'SphinxHowTo.tex').read_text(encoding='utf8')
|
2017-12-21 05:23:20 -06:00
|
|
|
assert '\\usepackage[,numfigreset=2]{sphinx}' in result
|
2017-12-18 06:02:09 -06:00
|
|
|
|
|
|
|
|
2018-09-03 07:18:58 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic')
|
2014-09-26 22:47:27 -05:00
|
|
|
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()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
2014-09-28 07:00:51 -05:00
|
|
|
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
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-babel')
|
2016-01-15 20:29:31 -06:00
|
|
|
def test_babel_with_no_language_settings(app, status, warning):
|
2015-08-20 22:59:54 -05:00
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-08-20 22:59:54 -05:00
|
|
|
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
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
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)
|
2022-01-08 10:02:32 -06:00
|
|
|
assert '\\shorthandoff{"}' in result
|
2015-08-20 22:59:54 -05:00
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{page}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2015-08-20 22:59:54 -05:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'de'})
|
2016-01-15 20:29:31 -06:00
|
|
|
def test_babel_with_language_de(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-01-15 20:29:31 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,ngerman]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsngerman{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\shorthandoff{"}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{Seite}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsngerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsngerman{\renewcommand{\tablename}{Table.\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2016-01-15 20:29:31 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'ru'})
|
2016-01-15 20:29:31 -06:00
|
|
|
def test_babel_with_language_ru(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-01-15 20:29:31 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,russian]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' not in result
|
2016-01-15 20:29:31 -06:00
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsrussian{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
2018-06-06 11:55:49 -05:00
|
|
|
assert '\\shorthandoff{"}' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{страница}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsrussian{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsrussian{\renewcommand{\tablename}{Table.\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2016-04-16 04:28:15 -05:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'tr'})
|
2016-04-16 04:28:15 -05:00
|
|
|
def test_babel_with_language_tr(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-04-16 04:28:15 -05:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,turkish]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsturkish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
|
|
|
assert '\\shorthandoff{=}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{sayfa}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsturkish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsturkish{\renewcommand{\tablename}{Table.\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2016-01-15 20:29:31 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-babel',
|
|
|
|
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()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-08-20 22:59:54 -05:00
|
|
|
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
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
assert '\\usepackage[Sonny]{fncychap}' not in result
|
|
|
|
assert '\\renewcommand{\\contentsname}{Table of content}\n' in result
|
2016-04-16 04:28:15 -05:00
|
|
|
assert '\\shorthandoff' not in result
|
2016-01-15 20:29:31 -06:00
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{ページ}' in result
|
2019-01-05 07:42:20 -06:00
|
|
|
assert '\\@iden{\\renewcommand{\\figurename}{Fig.\\@{} }}' in result
|
|
|
|
assert '\\@iden{\\renewcommand{\\tablename}{Table.\\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2016-01-15 20:29:31 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'unknown'})
|
2016-01-15 20:29:31 -06:00
|
|
|
def test_babel_with_unknown_language(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-01-15 20:29:31 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,english]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{babel}' in result
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' in result
|
2016-01-15 20:29:31 -06:00
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
2018-06-06 11:55:49 -05:00
|
|
|
assert '\\shorthandoff' 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
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{page}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2015-11-29 01:57:25 -06:00
|
|
|
|
2018-04-21 04:45:28 -05:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'de', 'latex_engine': 'lualatex'})
|
|
|
|
def test_polyglossia_with_language_de(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-04-21 04:45:28 -05:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,german]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{polyglossia}' in result
|
|
|
|
assert '\\setmainlanguage[spelling=new]{german}' in result
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' not in result
|
2018-04-21 04:45:28 -05:00
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsgerman{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
|
|
|
assert '\\shorthandoff' not in result
|
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{Seite}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2018-04-21 04:45:28 -05:00
|
|
|
|
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='latex-babel',
|
|
|
|
confoverrides={'language': 'de-1901', 'latex_engine': 'lualatex'})
|
|
|
|
def test_polyglossia_with_language_de_1901(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-04-21 04:45:28 -05:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\documentclass[letterpaper,10pt,german]{sphinxmanual}' in result
|
|
|
|
assert '\\usepackage{polyglossia}' in result
|
|
|
|
assert '\\setmainlanguage[spelling=old]{german}' in result
|
2021-01-20 09:48:35 -06:00
|
|
|
assert '\\usepackage{tgtermes}' not in result
|
2018-04-21 04:45:28 -05:00
|
|
|
assert '\\usepackage[Sonny]{fncychap}' in result
|
|
|
|
assert ('\\addto\\captionsgerman{\\renewcommand{\\contentsname}{Table of content}}\n'
|
|
|
|
in result)
|
|
|
|
assert '\\shorthandoff' not in result
|
|
|
|
|
2018-08-10 08:19:55 -05:00
|
|
|
# sphinxmessages.sty
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
2018-08-10 08:19:55 -05:00
|
|
|
print(result)
|
|
|
|
assert r'\def\pageautorefname{page}' in result
|
2019-01-05 04:00:19 -06:00
|
|
|
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
|
|
|
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.\@{} }}' in result
|
2018-08-10 08:19:55 -05:00
|
|
|
|
2018-04-21 04:45:28 -05:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex')
|
2015-11-29 01:57:25 -06:00
|
|
|
def test_footnote(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
2015-11-29 01:57:25 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('\\sphinxAtStartPar\n%\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
|
|
|
'numbered\n%\n\\end{footnote}') in result
|
2016-10-15 05:09:58 -05:00
|
|
|
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
|
2018-04-28 04:09:33 -05:00
|
|
|
assert '\\sphinxcite{footnote:bar}' in result
|
2021-01-29 03:09:36 -06:00
|
|
|
assert ('\\bibitem[bar]{footnote:bar}\n\\sphinxAtStartPar\ncite\n') in result
|
2017-05-04 09:10:58 -05:00
|
|
|
assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result
|
2022-10-12 10:15:40 -05:00
|
|
|
assert ('\\sphinxmidrule\n\\sphinxtableatstartofbodyhook%\n'
|
|
|
|
'\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n'
|
2017-02-18 09:26:00 -06:00
|
|
|
'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n'
|
2021-01-28 17:24:44 -06:00
|
|
|
'footnote in table header\n%\n\\end{footnotetext}\\ignorespaces '
|
2021-01-29 03:09:36 -06:00
|
|
|
'\n\\sphinxAtStartPar\n'
|
|
|
|
'VIDIOC\\_CROPCAP\n&\n\\sphinxAtStartPar\n') in result
|
2017-02-18 09:26:00 -06:00
|
|
|
assert ('Information about VIDIOC\\_CROPCAP %\n'
|
|
|
|
'\\begin{footnote}[6]\\sphinxAtStartFootnote\n'
|
2022-10-12 10:15:40 -05:00
|
|
|
'footnote in table not in header\n%\n\\end{footnote}\n\\\\\n'
|
|
|
|
'\\sphinxbottomrule\n\\end{tabulary}\n'
|
|
|
|
'\\sphinxtableafterendhook\\par\n\\sphinxattableend\\end{savenotes}\n') in result
|
2015-12-02 19:33:15 -06:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('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()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-12-02 19:33:15 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2016-12-08 14:43:04 -06:00
|
|
|
assert ('\\caption{This is the figure caption with a reference to '
|
2018-04-28 04:09:33 -05:00
|
|
|
'\\sphinxcite{index:authoryear}.}' in result)
|
2015-12-02 20:39:25 -06:00
|
|
|
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
|
2017-05-04 09:10:58 -05:00
|
|
|
assert ('\\sphinxcaption{The table title with a reference'
|
2017-05-01 09:22:04 -05:00
|
|
|
' to {[}AuthorYear{]}}' in result)
|
2018-05-22 09:47:21 -05:00
|
|
|
assert '\\subsubsection*{The rubric title with a reference to {[}AuthorYear{]}}' in result
|
2022-02-05 23:33:29 -06:00
|
|
|
assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[6]}\n'
|
2016-12-08 14:43:04 -06:00
|
|
|
'\\label{\\detokenize{index:the-section-with-a-reference-to}}'
|
2022-02-13 05:28:52 -06:00
|
|
|
'%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n'
|
2016-10-15 05:09:58 -05:00
|
|
|
'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 '
|
2022-02-05 23:54:21 -06:00
|
|
|
'\\sphinxfootnotemark[8].}\\label{\\detokenize{index:id35}}\\end{figure}\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'%\n\\begin{footnotetext}[8]\\sphinxAtStartFootnote\n'
|
2020-11-15 02:03:26 -06:00
|
|
|
'Footnote in caption\n%\n\\end{footnotetext}') in result
|
2022-02-05 23:33:29 -06:00
|
|
|
assert ('\\sphinxcaption{footnote \\sphinxfootnotemark[9] in '
|
2022-02-05 23:54:21 -06:00
|
|
|
'caption of normal table}\\label{\\detokenize{index:id36}}') in result
|
2022-02-05 23:33:29 -06:00
|
|
|
assert ('\\caption{footnote \\sphinxfootnotemark[10] '
|
|
|
|
'in caption \\sphinxfootnotemark[11] of longtable\\strut}') in result
|
2022-10-12 10:15:40 -05:00
|
|
|
assert ('\\endlastfoot\n\\sphinxtableatstartofbodyhook\n%\n'
|
|
|
|
'\\begin{footnotetext}[10]\\sphinxAtStartFootnote\n'
|
2017-02-14 16:30:50 -06:00
|
|
|
'Foot note in longtable\n%\n\\end{footnotetext}\\ignorespaces %\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[11]\\sphinxAtStartFootnote\n'
|
2017-02-14 16:30:50 -06:00
|
|
|
'Second footnote in caption of longtable\n') in result
|
2019-12-05 11:19:38 -06:00
|
|
|
assert ('This is a reference to the code\\sphinxhyphen{}block in the footnote:\n'
|
2017-02-12 11:02:51 -06:00
|
|
|
'{\\hyperref[\\detokenize{index:codeblockinfootnote}]'
|
2016-12-08 14:43:04 -06:00
|
|
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{I am in a footnote}}}}') in result
|
2021-01-29 03:09:36 -06:00
|
|
|
assert ('&\n\\sphinxAtStartPar\nThis is one more footnote with some code in it %\n'
|
2022-02-05 23:33:29 -06:00
|
|
|
'\\begin{footnote}[12]\\sphinxAtStartFootnote\n'
|
2017-02-14 16:30:50 -06:00
|
|
|
'Third footnote in longtable\n') in result
|
2017-06-16 07:24:40 -05:00
|
|
|
assert ('\\end{sphinxVerbatim}\n%\n\\end{footnote}.\n') in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert '\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]' in result
|
2015-12-06 20:02:45 -06:00
|
|
|
|
|
|
|
|
2022-02-05 23:54:21 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='footnotes')
|
|
|
|
def test_footnote_referred_multiple_times(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2022-02-05 23:54:21 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
|
2022-02-13 05:28:52 -06:00
|
|
|
assert ('Explicitly numbered footnote: %\n'
|
|
|
|
'\\begin{footnote}[100]'
|
2022-02-05 23:54:21 -06:00
|
|
|
'\\sphinxAtStartFootnote\nNumbered footnote\n%\n'
|
|
|
|
'\\end{footnote} \\sphinxfootnotemark[100]\n'
|
|
|
|
in result)
|
2022-02-13 05:28:52 -06:00
|
|
|
assert ('Named footnote: %\n'
|
|
|
|
'\\begin{footnote}[13]'
|
2022-02-05 23:54:21 -06:00
|
|
|
'\\sphinxAtStartFootnote\nNamed footnote\n%\n'
|
|
|
|
'\\end{footnote} \\sphinxfootnotemark[13]\n'
|
|
|
|
in result)
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='footnotes',
|
|
|
|
confoverrides={'latex_show_urls': 'inline'})
|
2015-12-06 20:02:45 -06:00
|
|
|
def test_latex_show_urls_is_inline(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-12-06 20:02:45 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('Same footnote number %\n'
|
|
|
|
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
2016-12-08 14:43:04 -06:00
|
|
|
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Auto footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
2016-12-08 14:43:04 -06:00
|
|
|
'footnote in baz\n%\n\\end{footnote} in baz.rst') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('\\phantomsection\\label{\\detokenize{index:id38}}'
|
2016-12-08 14:43:04 -06:00
|
|
|
'{\\hyperref[\\detokenize{index:the-section'
|
|
|
|
'-with-a-reference-to-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 '
|
2018-04-28 04:09:33 -05:00
|
|
|
'\\sphinxcite{index:authoryear}}}}') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('\\phantomsection\\label{\\detokenize{index:id39}}'
|
2016-12-08 14:43:04 -06:00
|
|
|
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-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'
|
2017-01-25 10:13:17 -06:00
|
|
|
'First\n%\n\\end{footnote}') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('Second footnote: %\n'
|
|
|
|
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
2022-02-05 23:33:29 -06:00
|
|
|
'Second\n%\n\\end{footnote}\n') in result
|
2019-12-05 11:19:38 -06:00
|
|
|
assert '\\sphinxhref{http://sphinx-doc.org/}{Sphinx} (http://sphinx\\sphinxhyphen{}doc.org/)' in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
2018-04-20 07:21:46 -05:00
|
|
|
'Third \\sphinxfootnotemark[4]\n%\n\\end{footnote}%\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n'
|
2018-04-20 07:21:46 -05:00
|
|
|
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
2022-02-05 23:33:29 -06:00
|
|
|
assert ('Fourth footnote: %\n\\begin{footnote}[5]\\sphinxAtStartFootnote\n'
|
|
|
|
'Fourth\n%\n\\end{footnote}\n') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert ('\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde} '
|
2019-12-05 11:19:38 -06:00
|
|
|
'(http://sphinx\\sphinxhyphen{}doc.org/\\textasciitilde{}test/)') in result
|
2021-12-20 05:07:20 -06:00
|
|
|
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{URL in term} '
|
2022-02-19 01:08:05 -06:00
|
|
|
'(http://sphinx\\sphinxhyphen{}doc.org/)}\n'
|
|
|
|
'\\sphinxAtStartPar\nDescription' in result)
|
|
|
|
assert ('\\sphinxlineitem{Footnote in term \\sphinxfootnotemark[7]}%\n'
|
2023-03-23 16:58:38 -05:00
|
|
|
'\\begin{footnotetext}[7]\\sphinxAtStartFootnote\n' in result)
|
2022-02-13 05:28:52 -06:00
|
|
|
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{URL in term} '
|
|
|
|
'(http://sphinx\\sphinxhyphen{}doc.org/)}\n'
|
|
|
|
'\\sphinxAtStartPar\nDescription' in result)
|
|
|
|
assert ('\\sphinxlineitem{Footnote in term \\sphinxfootnotemark[7]}%\n'
|
|
|
|
'\\begin{footnotetext}[7]\\sphinxAtStartFootnote\n'
|
2021-01-28 17:24:44 -06:00
|
|
|
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
2021-01-29 03:09:36 -06:00
|
|
|
'\n\\sphinxAtStartPar\nDescription') in result
|
2021-12-20 05:07:20 -06:00
|
|
|
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist} '
|
|
|
|
'(http://sphinx\\sphinxhyphen{}doc.org/)}'
|
|
|
|
'\n\\sphinxAtStartPar\nDescription') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert '\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result
|
|
|
|
assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{sphinx\\sphinxhyphen{}dev@googlegroups.com}') in result
|
2021-02-01 17:00:00 -06:00
|
|
|
assert '\\begin{savenotes}\\begin{fulllineitems}' not in result
|
2015-12-06 20:02:45 -06:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='footnotes',
|
|
|
|
confoverrides={'latex_show_urls': 'footnote'})
|
2015-12-06 20:02:45 -06:00
|
|
|
def test_latex_show_urls_is_footnote(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-12-06 20:02:45 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('Same footnote number %\n'
|
|
|
|
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
2016-12-08 14:43:04 -06:00
|
|
|
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Auto footnote number %\n\\begin{footnote}[2]\\sphinxAtStartFootnote\n'
|
2016-12-08 14:43:04 -06:00
|
|
|
'footnote in baz\n%\n\\end{footnote} in baz.rst') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('\\phantomsection\\label{\\detokenize{index:id38}}'
|
2016-12-08 14:43:04 -06:00
|
|
|
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to-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 '
|
2018-04-28 04:09:33 -05:00
|
|
|
'to \\sphinxcite{index:authoryear}}}}') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('\\phantomsection\\label{\\detokenize{index:id39}}'
|
2016-12-08 14:43:04 -06:00
|
|
|
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to}]'
|
|
|
|
'{\\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'
|
2017-01-25 10:13:17 -06:00
|
|
|
'First\n%\n\\end{footnote}') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('Second footnote: %\n'
|
|
|
|
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
2017-01-25 10:13:17 -06:00
|
|
|
'Second\n%\n\\end{footnote}') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert ('\\sphinxhref{http://sphinx-doc.org/}{Sphinx}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'%\n\\begin{footnote}[4]\\sphinxAtStartFootnote\n'
|
2017-03-11 09:53:53 -06:00
|
|
|
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n\\end{footnote}') in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Third footnote: %\n\\begin{footnote}[6]\\sphinxAtStartFootnote\n'
|
2018-04-20 07:21:46 -05:00
|
|
|
'Third \\sphinxfootnotemark[7]\n%\n\\end{footnote}%\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[7]\\sphinxAtStartFootnote\n'
|
2018-04-20 07:21:46 -05:00
|
|
|
'Footnote inside footnote\n%\n'
|
|
|
|
'\\end{footnotetext}\\ignorespaces') in result
|
2022-02-05 23:33:29 -06:00
|
|
|
assert ('Fourth footnote: %\n\\begin{footnote}[8]\\sphinxAtStartFootnote\n'
|
|
|
|
'Fourth\n%\n\\end{footnote}\n') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert ('\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}'
|
2016-10-15 05:09:58 -05:00
|
|
|
'%\n\\begin{footnote}[5]\\sphinxAtStartFootnote\n'
|
2017-03-11 09:53:53 -06:00
|
|
|
'\\sphinxnolinkurl{http://sphinx-doc.org/~test/}\n%\n\\end{footnote}') in result
|
2021-12-20 05:07:20 -06:00
|
|
|
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}'
|
2022-02-19 01:08:05 -06:00
|
|
|
'{URL in term}\\sphinxfootnotemark[10]}%\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[10]'
|
2021-02-05 07:56:23 -06:00
|
|
|
'\\sphinxAtStartFootnote\n'
|
2017-03-11 09:53:53 -06:00
|
|
|
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
2021-01-29 03:09:36 -06:00
|
|
|
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
2022-02-19 01:08:05 -06:00
|
|
|
assert ('\\sphinxlineitem{Footnote in term \\sphinxfootnotemark[12]}%\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[12]'
|
2021-02-05 07:56:23 -06:00
|
|
|
'\\sphinxAtStartFootnote\n'
|
2021-01-28 17:24:44 -06:00
|
|
|
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
2021-01-29 03:09:36 -06:00
|
|
|
'\n\\sphinxAtStartPar\nDescription') in result
|
2021-12-20 05:07:20 -06:00
|
|
|
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}'
|
2022-02-19 01:08:05 -06:00
|
|
|
'\\sphinxfootnotemark[11]}%\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[11]'
|
2021-02-05 07:56:23 -06:00
|
|
|
'\\sphinxAtStartFootnote\n'
|
2017-03-11 09:53:53 -06:00
|
|
|
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
2021-01-29 03:09:36 -06:00
|
|
|
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert ('\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result)
|
|
|
|
assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{sphinx\\sphinxhyphen{}dev@googlegroups.com}\n') in result
|
2021-02-01 17:00:00 -06:00
|
|
|
assert '\\begin{savenotes}\\begin{fulllineitems}' in result
|
2015-12-06 20:02:45 -06:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='footnotes',
|
|
|
|
confoverrides={'latex_show_urls': 'no'})
|
2015-12-06 20:02:45 -06:00
|
|
|
def test_latex_show_urls_is_no(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-12-06 20:02:45 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('Same footnote number %\n'
|
|
|
|
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
2016-10-15 05:09:58 -05:00
|
|
|
'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
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('\\phantomsection\\label{\\detokenize{index:id38}}'
|
2016-12-08 14:43:04 -06:00
|
|
|
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to-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 '
|
2018-04-28 04:09:33 -05:00
|
|
|
'to \\sphinxcite{index:authoryear}}}}') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('\\phantomsection\\label{\\detokenize{index:id39}}'
|
2016-12-08 14:43:04 -06:00
|
|
|
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-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'
|
2017-01-25 10:13:17 -06:00
|
|
|
'First\n%\n\\end{footnote}') in result
|
2022-02-05 23:54:21 -06:00
|
|
|
assert ('Second footnote: %\n'
|
|
|
|
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
2017-01-25 10:13:17 -06:00
|
|
|
'Second\n%\n\\end{footnote}') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert '\\sphinxhref{http://sphinx-doc.org/}{Sphinx}' in result
|
2016-10-15 05:09:58 -05:00
|
|
|
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
2018-04-20 07:21:46 -05:00
|
|
|
'Third \\sphinxfootnotemark[4]\n%\n\\end{footnote}%\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n'
|
2018-04-20 07:21:46 -05:00
|
|
|
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
2022-02-05 23:33:29 -06:00
|
|
|
assert ('Fourth footnote: %\n\\begin{footnote}[5]\\sphinxAtStartFootnote\n'
|
|
|
|
'Fourth\n%\n\\end{footnote}\n') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert '\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}' in result
|
2022-02-19 01:08:05 -06:00
|
|
|
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{URL in term}}\n'
|
|
|
|
'\\sphinxAtStartPar\nDescription') in result
|
|
|
|
assert ('\\sphinxlineitem{Footnote in term \\sphinxfootnotemark[7]}%\n'
|
2022-02-13 05:28:52 -06:00
|
|
|
'\\begin{footnotetext}[7]\\sphinxAtStartFootnote\n'
|
2021-01-28 17:24:44 -06:00
|
|
|
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
2021-01-29 03:09:36 -06:00
|
|
|
'\n\\sphinxAtStartPar\nDescription') in result
|
2021-12-20 05:07:20 -06:00
|
|
|
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}}'
|
|
|
|
'\n\\sphinxAtStartPar\nDescription') in result
|
2017-03-11 09:53:53 -06:00
|
|
|
assert ('\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result)
|
|
|
|
assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}'
|
2019-12-05 11:19:38 -06:00
|
|
|
'{sphinx\\sphinxhyphen{}dev@googlegroups.com}\n') in result
|
2021-02-01 17:00:00 -06:00
|
|
|
assert '\\begin{savenotes}\\begin{fulllineitems}' not in result
|
2016-01-05 01:48:22 -06:00
|
|
|
|
|
|
|
|
2018-04-10 12:01:03 -05:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='footnotes',
|
|
|
|
confoverrides={'latex_show_urls': 'footnote',
|
|
|
|
'rst_prolog': '.. |URL| replace:: `text <http://www.example.com/>`__'})
|
|
|
|
def test_latex_show_urls_footnote_and_substitutions(app, status, warning):
|
|
|
|
# hyperlinks in substitutions should not effect to make footnotes (refs: #4784)
|
|
|
|
test_latex_show_urls_is_footnote(app, status, warning)
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='image-in-section')
|
2015-09-16 05:08:12 -05:00
|
|
|
def test_image_in_section(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2015-09-16 05:08:12 -05:00
|
|
|
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
|
|
|
|
|
|
|
|
2018-02-13 10:34:50 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic',
|
|
|
|
confoverrides={'latex_logo': 'notfound.jpg'})
|
2016-01-05 01:48:22 -06:00
|
|
|
def test_latex_logo_if_not_found(app, status, warning):
|
2023-02-17 17:46:31 -06:00
|
|
|
with pytest.raises(SphinxError):
|
2016-01-05 01:48:22 -06:00
|
|
|
app.builder.build_all()
|
2016-01-05 10:34:29 -06:00
|
|
|
|
|
|
|
|
2017-12-20 14:30:05 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='toctree-maxdepth')
|
2016-01-05 10:34:29 -06:00
|
|
|
def test_toctree_maxdepth_manual(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-01-05 10:34:29 -06:00
|
|
|
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
|
2017-12-20 14:30:05 -06:00
|
|
|
assert '\\chapter{Foo}' in result
|
2016-01-05 10:34:29 -06:00
|
|
|
|
2017-12-23 06:20:32 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_documents': [
|
2018-09-03 07:18:58 -05:00
|
|
|
('index', 'python.tex', 'Sphinx Tests Documentation',
|
2017-01-05 10:14:47 -06:00
|
|
|
'Georg Brandl', 'howto'),
|
|
|
|
]})
|
2016-01-05 10:34:29 -06:00
|
|
|
def test_toctree_maxdepth_howto(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-01-05 10:34:29 -06:00
|
|
|
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
|
2017-12-20 14:30:05 -06:00
|
|
|
assert '\\section{Foo}' in result
|
2016-01-20 20:32:25 -06:00
|
|
|
|
2017-12-23 06:20:32 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
2020-11-24 09:50:36 -06:00
|
|
|
confoverrides={'root_doc': 'foo'})
|
2016-01-20 20:32:25 -06:00
|
|
|
def test_toctree_not_found(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-01-20 20:32:25 -06:00
|
|
|
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
|
2017-12-20 14:30:05 -06:00
|
|
|
assert '\\chapter{Foo A}' in result
|
2016-01-20 20:32:25 -06:00
|
|
|
|
2017-12-23 06:20:32 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
2020-11-24 09:50:36 -06:00
|
|
|
confoverrides={'root_doc': 'bar'})
|
2016-01-20 20:32:25 -06:00
|
|
|
def test_toctree_without_maxdepth(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-01-20 20:32:25 -06:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
2020-11-24 09:50:36 -06:00
|
|
|
confoverrides={'root_doc': 'qux'})
|
2016-05-26 09:23:07 -05:00
|
|
|
def test_toctree_with_deeper_maxdepth(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-05-26 09:23:07 -05:00
|
|
|
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
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': None})
|
2016-02-23 10:30:17 -06:00
|
|
|
def test_latex_toplevel_sectioning_is_None(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-02-23 10:30:17 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\chapter{Foo}' in result
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'part'})
|
2016-02-23 10:30:17 -06:00
|
|
|
def test_latex_toplevel_sectioning_is_part(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-02-23 10:30:17 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\part{Foo}' in result
|
2017-12-20 14:30:05 -06:00
|
|
|
assert '\\chapter{Foo A}' in result
|
|
|
|
assert '\\chapter{Foo B}' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'part',
|
|
|
|
'latex_documents': [
|
2018-09-03 07:18:58 -05:00
|
|
|
('index', 'python.tex', 'Sphinx Tests Documentation',
|
2023-02-17 16:11:14 -06:00
|
|
|
'Georg Brandl', 'howto'),
|
2017-12-20 14:30:05 -06:00
|
|
|
]})
|
|
|
|
def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2017-12-20 14:30:05 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\part{Foo}' in result
|
|
|
|
assert '\\section{Foo A}' in result
|
|
|
|
assert '\\section{Foo B}' in result
|
2016-02-23 10:30:17 -06:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'chapter'})
|
2016-02-23 10:30:17 -06:00
|
|
|
def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-02-23 10:30:17 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\chapter{Foo}' in result
|
|
|
|
|
|
|
|
|
2017-12-20 14:30:05 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'chapter',
|
|
|
|
'latex_documents': [
|
2018-09-03 07:18:58 -05:00
|
|
|
('index', 'python.tex', 'Sphinx Tests Documentation',
|
2023-02-17 16:11:14 -06:00
|
|
|
'Georg Brandl', 'howto'),
|
2017-12-20 14:30:05 -06:00
|
|
|
]})
|
|
|
|
def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2017-12-20 14:30:05 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\section{Foo}' in result
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'latex', testroot='toctree-maxdepth',
|
|
|
|
confoverrides={'latex_toplevel_sectioning': 'section'})
|
2016-02-23 10:30:17 -06:00
|
|
|
def test_latex_toplevel_sectioning_is_section(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-02-23 10:30:17 -06:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
assert '\\section{Foo}' in result
|
2016-11-04 17:57:00 -05:00
|
|
|
|
2017-01-25 10:13:17 -06:00
|
|
|
|
2016-11-05 05:50:12 -05:00
|
|
|
@skip_if_stylefiles_notfound
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='maxlistdepth')
|
2016-11-04 17:57:00 -05:00
|
|
|
def test_maxlistdepth_at_ten(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2016-11-04 17:57:00 -05:00
|
|
|
print(result)
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
2018-09-03 07:18:58 -05:00
|
|
|
compile_latex_document(app, 'python.tex')
|
2017-02-03 22:06:12 -06:00
|
|
|
|
|
|
|
|
2022-10-17 04:19:25 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-table',
|
|
|
|
confoverrides={'latex_table_style': []})
|
2018-01-18 07:33:17 -06:00
|
|
|
@pytest.mark.test_params(shared_result='latex-table')
|
2017-02-07 19:48:12 -06:00
|
|
|
def test_latex_table_tabulars(app, status, warning):
|
2017-02-03 22:06:12 -06:00
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2017-02-03 22:06:12 -06:00
|
|
|
tables = {}
|
2017-05-11 04:23:38 -05:00
|
|
|
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
|
2017-02-03 22:06:12 -06:00
|
|
|
sectname, content = chap.split('}', 1)
|
2022-02-13 05:19:41 -06:00
|
|
|
content = re.sub(r'\\sphinxstepscope', '', content) # filter a separator
|
2017-02-07 08:43:56 -06:00
|
|
|
tables[sectname] = content.strip()
|
2017-02-03 22:06:12 -06:00
|
|
|
|
2017-05-11 04:23:38 -05:00
|
|
|
def get_expected(name):
|
2022-04-26 21:04:19 -05:00
|
|
|
return (app.srcdir / 'expects' / (name + '.tex')).read_text(encoding='utf8').strip()
|
2017-05-11 04:23:38 -05:00
|
|
|
|
2017-02-03 22:06:12 -06:00
|
|
|
# simple_table
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['simple table']
|
|
|
|
expected = get_expected('simple_table')
|
|
|
|
assert actual == expected
|
2017-02-04 09:23:35 -06:00
|
|
|
|
2017-02-03 22:06:12 -06:00
|
|
|
# table having :widths: option
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having :widths: option']
|
|
|
|
expected = get_expected('table_having_widths')
|
|
|
|
assert actual == expected
|
2017-02-04 07:29:40 -06:00
|
|
|
|
2017-02-07 19:34:57 -06:00
|
|
|
# table having :align: option (tabulary)
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having :align: option (tabulary)']
|
|
|
|
expected = get_expected('tabulary_having_widths')
|
|
|
|
assert actual == expected
|
2017-02-07 19:34:57 -06:00
|
|
|
|
|
|
|
# table having :align: option (tabular)
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having :align: option (tabular)']
|
|
|
|
expected = get_expected('tabular_having_widths')
|
|
|
|
assert actual == expected
|
2017-02-07 19:34:57 -06:00
|
|
|
|
2017-02-04 07:29:40 -06:00
|
|
|
# table with tabularcolumn
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table with tabularcolumn']
|
|
|
|
expected = get_expected('tabularcolumn')
|
|
|
|
assert actual == expected
|
2017-02-03 22:37:34 -06:00
|
|
|
|
2018-01-18 07:33:17 -06:00
|
|
|
# table with cell in first column having three paragraphs
|
|
|
|
actual = tables['table with cell in first column having three paragraphs']
|
|
|
|
expected = get_expected('table_having_threeparagraphs_cell_in_first_col')
|
|
|
|
assert actual == expected
|
|
|
|
|
2017-02-03 22:37:34 -06:00
|
|
|
# table having caption
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having caption']
|
|
|
|
expected = get_expected('table_having_caption')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
|
|
|
# table having verbatim
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having verbatim']
|
|
|
|
expected = get_expected('table_having_verbatim')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
|
|
|
# table having problematic cell
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having problematic cell']
|
|
|
|
expected = get_expected('table_having_problematic_cell')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
|
|
|
# table having both :widths: and problematic cell
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having both :widths: and problematic cell']
|
|
|
|
expected = get_expected('table_having_widths_and_problematic_cell')
|
|
|
|
assert actual == expected
|
2017-02-03 22:37:34 -06:00
|
|
|
|
2017-04-30 11:38:43 -05:00
|
|
|
# table having both stub columns and problematic cell
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['table having both stub columns and problematic cell']
|
|
|
|
expected = get_expected('table_having_stub_columns_and_problematic_cell')
|
|
|
|
assert actual == expected
|
2017-04-30 11:38:43 -05:00
|
|
|
|
2017-02-07 19:48:12 -06:00
|
|
|
|
2022-10-17 04:19:25 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-table',
|
|
|
|
confoverrides={'latex_table_style': []})
|
2018-01-18 07:33:17 -06:00
|
|
|
@pytest.mark.test_params(shared_result='latex-table')
|
2017-02-07 19:48:12 -06:00
|
|
|
def test_latex_table_longtable(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2017-02-07 19:48:12 -06:00
|
|
|
tables = {}
|
2017-05-11 04:23:38 -05:00
|
|
|
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
|
2017-02-07 19:48:12 -06:00
|
|
|
sectname, content = chap.split('}', 1)
|
2022-02-13 05:19:41 -06:00
|
|
|
content = re.sub(r'\\sphinxstepscope', '', content) # filter a separator
|
2017-02-07 19:48:12 -06:00
|
|
|
tables[sectname] = content.strip()
|
|
|
|
|
2017-05-11 04:23:38 -05:00
|
|
|
def get_expected(name):
|
2022-04-26 21:04:19 -05:00
|
|
|
return (app.srcdir / 'expects' / (name + '.tex')).read_text(encoding='utf8').strip()
|
2017-05-11 04:23:38 -05:00
|
|
|
|
2017-02-03 22:37:34 -06:00
|
|
|
# longtable
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable']
|
|
|
|
expected = get_expected('longtable')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
|
|
|
# longtable having :widths: option
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable having :widths: option']
|
|
|
|
expected = get_expected('longtable_having_widths')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
2017-02-07 19:34:57 -06:00
|
|
|
# longtable having :align: option
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable having :align: option']
|
|
|
|
expected = get_expected('longtable_having_align')
|
|
|
|
assert actual == expected
|
2017-02-07 19:34:57 -06:00
|
|
|
|
2017-02-04 07:29:40 -06:00
|
|
|
# longtable with tabularcolumn
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable with tabularcolumn']
|
|
|
|
expected = get_expected('longtable_with_tabularcolumn')
|
|
|
|
assert actual == expected
|
2017-02-04 07:29:40 -06:00
|
|
|
|
2017-02-03 23:40:40 -06:00
|
|
|
# longtable having caption
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable having caption']
|
|
|
|
expected = get_expected('longtable_having_caption')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
|
|
|
# longtable having verbatim
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable having verbatim']
|
|
|
|
expected = get_expected('longtable_having_verbatim')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
|
|
|
# longtable having problematic cell
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable having problematic cell']
|
|
|
|
expected = get_expected('longtable_having_problematic_cell')
|
|
|
|
assert actual == expected
|
2017-02-03 23:40:40 -06:00
|
|
|
|
|
|
|
# longtable having both :widths: and problematic cell
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable having both :widths: and problematic cell']
|
|
|
|
expected = get_expected('longtable_having_widths_and_problematic_cell')
|
|
|
|
assert actual == expected
|
2017-02-10 21:19:12 -06:00
|
|
|
|
2017-04-30 11:38:43 -05:00
|
|
|
# longtable having both stub columns and problematic cell
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['longtable having both stub columns and problematic cell']
|
|
|
|
expected = get_expected('longtable_having_stub_columns_and_problematic_cell')
|
|
|
|
assert actual == expected
|
2017-04-30 11:38:43 -05:00
|
|
|
|
2017-02-10 21:19:12 -06:00
|
|
|
|
2022-10-17 04:19:25 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-table',
|
|
|
|
confoverrides={'latex_table_style': []})
|
2018-01-18 07:33:17 -06:00
|
|
|
@pytest.mark.test_params(shared_result='latex-table')
|
2017-02-10 21:19:12 -06:00
|
|
|
def test_latex_table_complex_tables(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2017-02-10 21:19:12 -06:00
|
|
|
tables = {}
|
2017-05-11 04:23:38 -05:00
|
|
|
for chap in re.split(r'\\(?:section|renewcommand){', result)[1:]:
|
2017-02-10 21:19:12 -06:00
|
|
|
sectname, content = chap.split('}', 1)
|
|
|
|
tables[sectname] = content.strip()
|
|
|
|
|
2017-05-11 04:23:38 -05:00
|
|
|
def get_expected(name):
|
2022-04-26 21:04:19 -05:00
|
|
|
return (app.srcdir / 'expects' / (name + '.tex')).read_text(encoding='utf8').strip()
|
2017-05-11 04:23:38 -05:00
|
|
|
|
2017-02-10 21:19:12 -06:00
|
|
|
# grid table
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['grid table']
|
|
|
|
expected = get_expected('gridtable')
|
|
|
|
assert actual == expected
|
2017-02-10 21:19:12 -06:00
|
|
|
|
2022-10-12 10:15:40 -05:00
|
|
|
# grid table with tabularcolumns
|
|
|
|
# MEMO: filename should end with tabularcolumns but tabularcolumn has been
|
|
|
|
# used in existing other cases
|
|
|
|
actual = tables['grid table with tabularcolumns having no vline']
|
|
|
|
expected = get_expected('gridtable_with_tabularcolumn')
|
|
|
|
assert actual == expected
|
|
|
|
|
2017-02-10 21:19:12 -06:00
|
|
|
# complex spanning cell
|
2017-05-11 04:23:38 -05:00
|
|
|
actual = tables['complex spanning cell']
|
|
|
|
expected = get_expected('complex_spanning_cell')
|
|
|
|
assert actual == expected
|
2017-04-03 20:44:53 -05:00
|
|
|
|
|
|
|
|
2022-10-17 04:19:25 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-table')
|
2022-10-12 10:15:40 -05:00
|
|
|
def test_latex_table_with_booktabs_and_colorrows(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
|
|
|
assert r'\PassOptionsToPackage{booktabs}{sphinx}' in result
|
|
|
|
assert r'\PassOptionsToPackage{colorrows}{sphinx}' in result
|
|
|
|
# tabularcolumns
|
|
|
|
assert r'\begin{longtable}[c]{|c|c|}' in result
|
|
|
|
# class: standard
|
|
|
|
assert r'\begin{tabulary}{\linewidth}[t]{|T|T|T|T|T|}' in result
|
|
|
|
assert r'\begin{longtable}[c]{ll}' in result
|
|
|
|
assert r'\begin{tabular}[t]{*{2}{\X{1}{2}}}' in result
|
|
|
|
assert r'\begin{tabular}[t]{\X{30}{100}\X{70}{100}}' in result
|
|
|
|
|
|
|
|
|
2018-03-29 07:44:04 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-table',
|
|
|
|
confoverrides={'templates_path': ['_mytemplates/latex']})
|
|
|
|
def test_latex_table_custom_template_caseA(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-03-29 07:44:04 -05:00
|
|
|
assert 'SALUT LES COPAINS' in result
|
|
|
|
|
2023-04-07 12:07:15 -05:00
|
|
|
# # TODO: deprecate '_t' template suffix support after 2024-12-31
|
|
|
|
assert 'TODO' not in result
|
|
|
|
assert 'AU REVOIR, KANIGGETS' in result
|
|
|
|
|
2018-03-29 07:44:04 -05:00
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-table',
|
|
|
|
confoverrides={'templates_path': ['_mytemplates']})
|
|
|
|
def test_latex_table_custom_template_caseB(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-03-29 07:44:04 -05:00
|
|
|
assert 'SALUT LES COPAINS' not in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-table')
|
|
|
|
@pytest.mark.test_params(shared_result='latex-table')
|
|
|
|
def test_latex_table_custom_template_caseC(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-03-29 07:44:04 -05:00
|
|
|
assert 'SALUT LES COPAINS' not in result
|
|
|
|
|
|
|
|
|
2017-04-03 20:44:53 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='directives-raw')
|
|
|
|
def test_latex_raw_directive(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2017-04-03 20:44:53 -05:00
|
|
|
|
|
|
|
# standard case
|
|
|
|
assert 'standalone raw directive (HTML)' not in result
|
|
|
|
assert ('\\label{\\detokenize{index:id1}}\n'
|
|
|
|
'standalone raw directive (LaTeX)' in result)
|
|
|
|
|
|
|
|
# with substitution
|
|
|
|
assert 'HTML: abc ghi' in result
|
|
|
|
assert 'LaTeX: abc def ghi' in result
|
2017-03-27 09:46:11 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='images')
|
2019-02-27 10:39:29 -06:00
|
|
|
def test_latex_images(app, status, warning):
|
2017-03-27 09:46:11 -05:00
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2019-02-27 10:39:29 -06:00
|
|
|
|
|
|
|
# images are copied
|
2017-03-27 09:46:11 -05:00
|
|
|
assert '\\sphinxincludegraphics{{python-logo}.png}' in result
|
|
|
|
assert (app.outdir / 'python-logo.png').exists()
|
2019-02-27 10:39:29 -06:00
|
|
|
|
|
|
|
# not found images
|
2017-03-27 09:46:12 -05:00
|
|
|
assert '\\sphinxincludegraphics{{NOT_EXIST}.PNG}' not in result
|
|
|
|
assert ('WARNING: Could not fetch remote image: '
|
2019-06-05 09:42:24 -05:00
|
|
|
'https://www.google.com/NOT_EXIST.PNG [404]' in warning.getvalue())
|
2017-09-20 03:20:43 -05:00
|
|
|
|
2019-02-27 10:39:29 -06:00
|
|
|
# an image having target
|
|
|
|
assert ('\\sphinxhref{https://www.sphinx-doc.org/}'
|
|
|
|
'{\\sphinxincludegraphics{{rimg}.png}}\n\n' in result)
|
|
|
|
|
2019-02-27 11:03:59 -06:00
|
|
|
# a centerized image having target
|
|
|
|
assert ('\\sphinxhref{https://www.python.org/}{{\\hspace*{\\fill}'
|
|
|
|
'\\sphinxincludegraphics{{rimg}.png}\\hspace*{\\fill}}}\n\n' in result)
|
|
|
|
|
2017-09-20 03:20:43 -05:00
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-index')
|
|
|
|
def test_latex_index(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-10-31 09:58:45 -05:00
|
|
|
assert ('A \\index{famous@\\spxentry{famous}}famous '
|
|
|
|
'\\index{equation@\\spxentry{equation}}equation:\n' in result)
|
|
|
|
assert ('\n\\index{Einstein@\\spxentry{Einstein}}'
|
|
|
|
'\\index{relativity@\\spxentry{relativity}}'
|
2021-01-29 03:09:36 -06:00
|
|
|
'\\ignorespaces \n\\sphinxAtStartPar\nand') in result
|
2018-10-31 09:58:45 -05:00
|
|
|
assert ('\n\\index{main \\sphinxleftcurlybrace{}@\\spxentry{'
|
|
|
|
'main \\sphinxleftcurlybrace{}}}\\ignorespaces ' in result)
|
2017-09-27 02:54:18 -05:00
|
|
|
|
|
|
|
|
2018-03-11 05:36:16 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-equations')
|
|
|
|
def test_latex_equations(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
|
|
|
expected = (app.srcdir / 'expects' / 'latex-equations.tex').read_text(encoding='utf8').strip()
|
2018-03-11 05:36:16 -05:00
|
|
|
|
|
|
|
assert expected in result
|
|
|
|
|
|
|
|
|
2017-09-27 02:54:18 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='image-in-parsed-literal')
|
|
|
|
def test_latex_image_in_parsed_literal(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2017-10-23 09:01:18 -05:00
|
|
|
assert ('{\\sphinxunactivateextrasandspace \\raisebox{-0.5\\height}'
|
2019-01-14 09:04:04 -06:00
|
|
|
'{\\sphinxincludegraphics[height=2.00000cm]{{pic}.png}}'
|
2017-09-27 05:43:28 -05:00
|
|
|
'}AFTER') in result
|
2018-02-18 00:37:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='nested-enumerated-list')
|
|
|
|
def test_latex_nested_enumerated_list(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2019-06-23 04:11:52 -05:00
|
|
|
assert ('\\sphinxsetlistlabels{\\arabic}{enumi}{enumii}{}{.}%\n'
|
2018-05-14 06:09:45 -05:00
|
|
|
'\\setcounter{enumi}{4}\n' in result)
|
2019-06-23 04:11:52 -05:00
|
|
|
assert ('\\sphinxsetlistlabels{\\alph}{enumii}{enumiii}{}{.}%\n'
|
2018-05-14 06:09:45 -05:00
|
|
|
'\\setcounter{enumii}{3}\n' in result)
|
2019-06-23 04:11:52 -05:00
|
|
|
assert ('\\sphinxsetlistlabels{\\arabic}{enumiii}{enumiv}{}{)}%\n'
|
2018-05-14 06:09:45 -05:00
|
|
|
'\\setcounter{enumiii}{9}\n' in result)
|
2019-06-23 04:11:52 -05:00
|
|
|
assert ('\\sphinxsetlistlabels{\\arabic}{enumiv}{enumv}{(}{)}%\n'
|
2018-05-14 06:09:45 -05:00
|
|
|
'\\setcounter{enumiv}{23}\n' in result)
|
2019-06-23 04:11:52 -05:00
|
|
|
assert ('\\sphinxsetlistlabels{\\roman}{enumii}{enumiii}{}{.}%\n'
|
2018-05-14 06:09:45 -05:00
|
|
|
'\\setcounter{enumii}{2}\n' in result)
|
2018-04-25 11:13:54 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='footnotes')
|
|
|
|
def test_latex_thebibliography(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-04-25 11:13:54 -05:00
|
|
|
print(result)
|
2018-05-03 09:38:42 -05:00
|
|
|
assert ('\\begin{sphinxthebibliography}{AuthorYe}\n'
|
2021-01-29 03:09:36 -06:00
|
|
|
'\\bibitem[AuthorYear]{index:authoryear}\n\\sphinxAtStartPar\n'
|
2018-04-25 11:13:54 -05:00
|
|
|
'Author, Title, Year\n'
|
|
|
|
'\\end{sphinxthebibliography}\n' in result)
|
2018-04-28 04:09:33 -05:00
|
|
|
assert '\\sphinxcite{index:authoryear}' in result
|
2018-05-23 07:41:45 -05:00
|
|
|
|
|
|
|
|
2018-05-19 01:20:30 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='glossary')
|
|
|
|
def test_latex_glossary(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2021-12-22 12:51:15 -06:00
|
|
|
assert (r'\sphinxlineitem{ähnlich\index{ähnlich@\spxentry{ähnlich}|spxpagem}'
|
2018-10-31 09:58:45 -05:00
|
|
|
r'\phantomsection'
|
2021-12-22 12:51:15 -06:00
|
|
|
r'\label{\detokenize{index:term-ahnlich}}}' in result)
|
2021-12-20 05:07:20 -06:00
|
|
|
assert (r'\sphinxlineitem{boson\index{boson@\spxentry{boson}|spxpagem}\phantomsection'
|
|
|
|
r'\label{\detokenize{index:term-boson}}}' in result)
|
|
|
|
assert (r'\sphinxlineitem{\sphinxstyleemphasis{fermion}'
|
2018-10-31 09:58:45 -05:00
|
|
|
r'\index{fermion@\spxentry{fermion}|spxpagem}'
|
2018-05-21 09:17:58 -05:00
|
|
|
r'\phantomsection'
|
2021-12-20 05:07:20 -06:00
|
|
|
r'\label{\detokenize{index:term-fermion}}}' in result)
|
|
|
|
assert (r'\sphinxlineitem{tauon\index{tauon@\spxentry{tauon}|spxpagem}\phantomsection'
|
|
|
|
r'\label{\detokenize{index:term-tauon}}}'
|
|
|
|
r'\sphinxlineitem{myon\index{myon@\spxentry{myon}|spxpagem}\phantomsection'
|
|
|
|
r'\label{\detokenize{index:term-myon}}}'
|
|
|
|
r'\sphinxlineitem{electron\index{electron@\spxentry{electron}|spxpagem}\phantomsection'
|
|
|
|
r'\label{\detokenize{index:term-electron}}}' in result)
|
|
|
|
assert (r'\sphinxlineitem{über\index{über@\spxentry{über}|spxpagem}\phantomsection'
|
|
|
|
r'\label{\detokenize{index:term-uber}}}' in result)
|
2018-05-18 07:21:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-labels')
|
|
|
|
def test_latex_labels(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2018-05-18 09:18:11 -05:00
|
|
|
|
|
|
|
# figures
|
2018-05-18 07:21:46 -05:00
|
|
|
assert (r'\caption{labeled figure}'
|
|
|
|
r'\label{\detokenize{index:id1}}'
|
|
|
|
r'\label{\detokenize{index:figure2}}'
|
|
|
|
r'\label{\detokenize{index:figure1}}'
|
|
|
|
r'\end{figure}' in result)
|
|
|
|
assert (r'\caption{labeled figure}'
|
2018-10-30 11:47:59 -05:00
|
|
|
'\\label{\\detokenize{index:figure3}}\n'
|
2021-01-29 03:09:36 -06:00
|
|
|
'\\begin{sphinxlegend}\n\\sphinxAtStartPar\n'
|
2021-01-28 17:24:44 -06:00
|
|
|
'with a legend\n\\end{sphinxlegend}\n'
|
2018-05-18 07:21:46 -05:00
|
|
|
r'\end{figure}' in result)
|
2018-05-18 09:18:11 -05:00
|
|
|
|
|
|
|
# code-blocks
|
|
|
|
assert (r'\def\sphinxLiteralBlockLabel{'
|
|
|
|
r'\label{\detokenize{index:codeblock2}}'
|
|
|
|
r'\label{\detokenize{index:codeblock1}}}' in result)
|
|
|
|
assert (r'\def\sphinxLiteralBlockLabel{'
|
|
|
|
r'\label{\detokenize{index:codeblock3}}}' in result)
|
2018-05-18 10:26:18 -05:00
|
|
|
|
|
|
|
# tables
|
|
|
|
assert (r'\sphinxcaption{table caption}'
|
|
|
|
r'\label{\detokenize{index:id2}}'
|
|
|
|
r'\label{\detokenize{index:table2}}'
|
|
|
|
r'\label{\detokenize{index:table1}}' in result)
|
|
|
|
assert (r'\sphinxcaption{table caption}'
|
|
|
|
r'\label{\detokenize{index:table3}}' in result)
|
2018-05-18 11:21:57 -05:00
|
|
|
|
|
|
|
# sections
|
|
|
|
assert ('\\chapter{subsection}\n'
|
|
|
|
r'\label{\detokenize{index:subsection}}'
|
|
|
|
r'\label{\detokenize{index:section2}}'
|
|
|
|
r'\label{\detokenize{index:section1}}' in result)
|
|
|
|
assert ('\\section{subsubsection}\n'
|
|
|
|
r'\label{\detokenize{index:subsubsection}}'
|
|
|
|
r'\label{\detokenize{index:section3}}' in result)
|
|
|
|
assert ('\\subsection{otherdoc}\n'
|
|
|
|
r'\label{\detokenize{otherdoc:otherdoc}}'
|
|
|
|
r'\label{\detokenize{otherdoc::doc}}' in result)
|
2018-09-03 07:18:58 -05:00
|
|
|
|
2020-07-18 19:43:11 -05:00
|
|
|
# Embedded standalone hyperlink reference (refs: #5948)
|
2019-02-03 02:35:51 -06:00
|
|
|
assert result.count(r'\label{\detokenize{index:section1}}') == 1
|
2019-02-03 08:20:26 -06:00
|
|
|
|
2018-09-03 07:18:58 -05:00
|
|
|
|
2019-05-14 05:40:37 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-figure-in-admonition')
|
|
|
|
def test_latex_figure_in_admonition(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2022-08-01 11:05:25 -05:00
|
|
|
assert r'\begin{figure}[H]' in result
|
2019-05-14 05:40:37 -05:00
|
|
|
|
2019-06-30 00:55:22 -05:00
|
|
|
|
2018-09-03 07:18:58 -05:00
|
|
|
def test_default_latex_documents():
|
|
|
|
from sphinx.util import texescape
|
|
|
|
texescape.init()
|
2020-11-24 09:50:36 -06:00
|
|
|
config = Config({'root_doc': 'index',
|
2019-01-07 08:05:43 -06:00
|
|
|
'project': 'STASI™ Documentation',
|
|
|
|
'author': "Wolfgang Schäuble & G'Beckstein."})
|
2018-09-03 07:18:58 -05:00
|
|
|
config.init_values()
|
2019-11-16 04:22:34 -06:00
|
|
|
config.add('latex_engine', None, True, None)
|
2019-12-28 04:36:55 -06:00
|
|
|
config.add('latex_theme', 'manual', True, None)
|
2019-01-07 08:05:43 -06:00
|
|
|
expected = [('index', 'stasi.tex', 'STASI™ Documentation',
|
2019-12-05 11:19:38 -06:00
|
|
|
r"Wolfgang Schäuble \& G\textquotesingle{}Beckstein.\@{}", 'manual')]
|
2018-09-03 07:18:58 -05:00
|
|
|
assert default_latex_documents(config) == expected
|
2019-01-28 12:34:11 -06:00
|
|
|
|
|
|
|
|
|
|
|
@skip_if_requested
|
|
|
|
@skip_if_stylefiles_notfound
|
2019-02-05 10:51:13 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-includegraphics')
|
2019-01-28 12:34:11 -06:00
|
|
|
def test_includegraphics_oversized(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
print(status.getvalue())
|
|
|
|
print(warning.getvalue())
|
|
|
|
compile_latex_document(app)
|
2019-03-10 01:52:51 -06:00
|
|
|
|
|
|
|
|
2019-03-09 02:41:12 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='index_on_title')
|
|
|
|
def test_index_on_title(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2019-03-09 02:41:12 -06:00
|
|
|
assert ('\\chapter{Test for index in top level title}\n'
|
|
|
|
'\\label{\\detokenize{contents:test-for-index-in-top-level-title}}'
|
|
|
|
'\\index{index@\\spxentry{index}}\n'
|
|
|
|
in result)
|
2019-10-20 08:29:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-unicode',
|
|
|
|
confoverrides={'latex_engine': 'pdflatex'})
|
|
|
|
def test_texescape_for_non_unicode_supported_engine(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2019-10-20 08:29:46 -05:00
|
|
|
print(result)
|
|
|
|
assert 'script small e: e' in result
|
|
|
|
assert 'double struck italic small i: i' in result
|
|
|
|
assert r'superscript: \(\sp{\text{0}}\), \(\sp{\text{1}}\)' in result
|
|
|
|
assert r'subscript: \(\sb{\text{0}}\), \(\sb{\text{1}}\)' in result
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-unicode',
|
|
|
|
confoverrides={'latex_engine': 'xelatex'})
|
|
|
|
def test_texescape_for_unicode_supported_engine(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2019-10-20 08:29:46 -05:00
|
|
|
print(result)
|
|
|
|
assert 'script small e: e' in result
|
|
|
|
assert 'double struck italic small i: i' in result
|
|
|
|
assert 'superscript: ⁰, ¹' in result
|
|
|
|
assert 'subscript: ₀, ₁' in result
|
2019-11-15 12:09:16 -06:00
|
|
|
|
2020-06-13 16:46:19 -05:00
|
|
|
|
2019-10-26 04:33:59 -05:00
|
|
|
@pytest.mark.sphinx('latex', testroot='basic',
|
|
|
|
confoverrides={'latex_elements': {'extrapackages': r'\usepackage{foo}'}})
|
|
|
|
def test_latex_elements_extrapackages(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
2019-10-26 04:33:59 -05:00
|
|
|
assert r'\usepackage{foo}' in result
|
2019-11-16 08:51:27 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='nested-tables')
|
|
|
|
def test_latex_nested_tables(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-12-29 18:06:11 -06:00
|
|
|
assert warning.getvalue() == ''
|
2021-05-15 15:53:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='latex-container')
|
|
|
|
def test_latex_container(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2022-04-26 21:04:19 -05:00
|
|
|
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
2021-07-04 14:15:56 -05:00
|
|
|
assert r'\begin{sphinxuseclass}{classname}' in result
|
|
|
|
assert r'\end{sphinxuseclass}' in result
|
2022-03-10 21:33:56 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='reST-code-role')
|
|
|
|
def test_latex_code_role(app):
|
2022-10-13 07:16:17 -05:00
|
|
|
app.build()
|
2022-03-10 21:33:56 -06:00
|
|
|
content = (app.outdir / 'python.tex').read_text()
|
|
|
|
|
|
|
|
common_content = (
|
|
|
|
r'\PYG{k}{def} '
|
|
|
|
r'\PYG{n+nf}{foo}'
|
|
|
|
r'\PYG{p}{(}'
|
|
|
|
r'\PYG{l+m+mi}{1} '
|
|
|
|
r'\PYG{o}{+} '
|
|
|
|
r'\PYG{l+m+mi}{2} '
|
|
|
|
r'\PYG{o}{+} '
|
|
|
|
r'\PYG{k+kc}{None} '
|
|
|
|
r'\PYG{o}{+} '
|
|
|
|
r'\PYG{l+s+s2}{\PYGZdq{}}'
|
|
|
|
r'\PYG{l+s+s2}{abc}'
|
|
|
|
r'\PYG{l+s+s2}{\PYGZdq{}}'
|
|
|
|
r'\PYG{p}{)}'
|
|
|
|
r'\PYG{p}{:} '
|
|
|
|
r'\PYG{k}{pass}')
|
2022-05-08 04:32:37 -05:00
|
|
|
assert (r'Inline \sphinxcode{\sphinxupquote{%' + '\n' +
|
|
|
|
common_content + '%\n}} code block') in content
|
2022-03-10 21:33:56 -06:00
|
|
|
assert (r'\begin{sphinxVerbatim}[commandchars=\\\{\}]' +
|
|
|
|
'\n' + common_content + '\n' + r'\end{sphinxVerbatim}') in content
|
2023-01-07 11:35:21 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('latex', testroot='images')
|
|
|
|
def test_copy_images(app, status, warning):
|
|
|
|
app.build()
|
|
|
|
|
|
|
|
test_dir = Path(app.outdir)
|
|
|
|
images = {
|
|
|
|
image.name for image in test_dir.rglob('*')
|
|
|
|
if image.suffix in {'.gif', '.pdf', '.png', '.svg'}
|
|
|
|
}
|
2023-01-10 08:18:46 -06:00
|
|
|
images.discard('python-logo.png')
|
2023-01-07 11:35:21 -06:00
|
|
|
assert images == {
|
|
|
|
'img.pdf',
|
|
|
|
'rimg.png',
|
|
|
|
'testimäge.png',
|
|
|
|
}
|