quickstart: Simplify generated conf.py (for latex)

This commit is contained in:
Takeshi KOMIYA 2018-09-03 21:18:58 +09:00
parent 353c3e9fd6
commit 68c90a26f1
31 changed files with 100 additions and 177 deletions

View File

@ -51,6 +51,7 @@ Incompatible changes
time of ``\sphinxtableofcontents``. This means that custom user definitions
from LaTeX preamble now get overwritten. Use ``\sphinxtableofcontentshook``
to insert custom user definitions. See :ref:`latex-macros`.
* quickstart: Simplify generated ``conf.py``
Deprecated
----------
@ -159,6 +160,8 @@ Bugs fixed
if passed as language option?
* #5179: LaTeX: (lualatex only) escaping of ``>`` by ``\textgreater{}`` is not
enough as ``\textgreater{}\textgreater{}`` applies TeX-ligature
* LaTeX: project name is not escaped if :confval:`latex_documents` omitted
* LaTeX: authors are not shown if :confval:`latex_documents` omitted
* HTML: Invalid HTML5 file is generated for a glossary having multiple terms for
one description (refs: #4611)

View File

@ -34,7 +34,7 @@ from sphinx.util.docutils import SphinxFileOutput, new_document
from sphinx.util.fileutil import copy_asset_file
from sphinx.util.i18n import format_date
from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.osutil import SEP, make_filename
from sphinx.util.osutil import SEP, make_filename_from_project
from sphinx.util.template import LaTeXRenderer
from sphinx.writers.latex import (
ADDITIONAL_SETTINGS, DEFAULT_SETTINGS, LaTeXWriter, LaTeXTranslator
@ -468,6 +468,16 @@ def default_latex_use_xindy(config):
return config.latex_engine in {'xelatex', 'lualatex'}
def default_latex_documents(config):
# type: (Config) -> List[Tuple[str, str, str, str, str]]
""" Better default latex_documents settings. """
return [(config.master_doc,
make_filename_from_project(config.project) + '.tex',
texescape.escape(config.project),
texescape.escape(config.author),
'manual')]
def setup(app):
# type: (Sphinx) -> Dict[str, Any]
app.add_builder(LaTeXBuilder)
@ -478,10 +488,7 @@ def setup(app):
app.add_config_value('latex_engine', default_latex_engine, None,
ENUM('pdflatex', 'xelatex', 'lualatex', 'platex'))
app.add_config_value('latex_documents',
lambda self: [(self.master_doc, make_filename(self.project) + '.tex',
self.project, '', 'manual')],
None)
app.add_config_value('latex_documents', default_latex_documents, None)
app.add_config_value('latex_logo', None, None, [str])
app.add_config_value('latex_appendices', [], None)
app.add_config_value('latex_use_latex_multicolumn', False, None)

View File

@ -103,35 +103,6 @@ html_static_path = ['{{ dot }}static']
# html_sidebars = {}
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, '{{ project_fn }}.tex', '{{ project_doc_texescaped_str }}',
'{{ author_texescaped_str }}', 'manual'),
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -1,7 +1,2 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]
def setup(app):
app.add_crossref_type(directivename="setting", rolename="setting")

View File

@ -1,7 +1,2 @@
extensions = ['sphinx.ext.graphviz']
exclude_patterns = ['_build']
latex_documents = [
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'manual'),
]

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'Math Extension Testing', 'Sphinx', 'report')
]

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'Math Extension Testing', 'Sphinx', 'report')
]

View File

@ -1,6 +1 @@
extensions = ['sphinx.ext.todo']
latex_documents = [
('index', 'TodoTests.tex', 'Todo Tests Documentation',
'Robin Banks', 'manual'),
]

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -1,11 +1,6 @@
html_theme = 'classic'
exclude_patterns = ['_build']
latex_documents = [
('index', 'SphinxTests.tex', 'Testing maxlistdepth=10',
'Georg Brandl', 'howto'),
]
latex_elements = {
'maxlistdepth': '10',
}

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -1,5 +1 @@
html_compact_lists = False
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -42,11 +42,6 @@ html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'}
applehelp_bundle_id = 'org.sphinx-doc.Sphinx.help'
applehelp_disable_external_tools = True
latex_documents = [
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl \\and someone else', 'manual'),
]
latex_additional_files = ['svgimg.svg']
coverage_c_path = ['special/*.h']

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -1,3 +0,0 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -1,5 +1 @@
extensions = ['sphinx.ext.doctest']
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]

View File

@ -3,7 +3,3 @@ import sys
sys.path.append(os.path.abspath('.'))
extensions = ['sphinx.ext.autodoc']
latex_documents = [
('index', 'test.tex', 'test-warnings', 'Sphinx', 'report')
]

View File

@ -17,6 +17,8 @@ from subprocess import Popen, PIPE
import pytest
from test_build_html import ENV_WARNINGS
from sphinx.builders.latex import default_latex_documents
from sphinx.config import Config
from sphinx.errors import SphinxError
from sphinx.testing.util import strip_escseq
from sphinx.util import docutils
@ -56,19 +58,18 @@ def kpsetest(*filenames):
# compile latex document with app.config.latex_engine
def compile_latex_document(app):
def compile_latex_document(app, filename='python.tex'):
# now, try to run latex over it
with cd(app.outdir):
try:
ensuredir(app.config.latex_engine)
# keep a copy of latex file for this engine in case test fails
copyfile('SphinxTests.tex',
app.config.latex_engine + '/SphinxTests.tex')
copyfile(filename, app.config.latex_engine + '/' + filename)
p = Popen([app.config.latex_engine,
'--halt-on-error',
'--interaction=nonstopmode',
'-output-directory=%s' % app.config.latex_engine,
'SphinxTests.tex'],
filename],
stdout=PIPE, stderr=PIPE)
except OSError: # most likely the latex executable was not found
raise pytest.skip.Exception
@ -115,13 +116,13 @@ def test_build_latex_doc(app, status, warning, engine, docclass):
# file from latex_additional_files
assert (app.outdir / 'svgimg.svg').isfile()
compile_latex_document(app)
compile_latex_document(app, 'sphinxtests.tex')
@pytest.mark.sphinx('latex')
def test_writer(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
result = (app.outdir / 'sphinxtests.tex').text(encoding='utf8')
assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n'
'\\noindent\\sphinxincludegraphics{{img}.png}\n'
@ -199,7 +200,7 @@ def test_latex_release(app, status, warning):
confoverrides={'numfig': True})
def test_numref(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -241,7 +242,7 @@ def test_numref(app, status, warning):
'section': 'SECTION-%s'}})
def test_numref_with_prefix1(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -289,7 +290,7 @@ def test_numref_with_prefix1(app, status, warning):
'section': 'SECTION_%s_'}})
def test_numref_with_prefix2(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -329,7 +330,7 @@ def test_numref_with_prefix2(app, status, warning):
confoverrides={'numfig': True, 'language': 'ja'})
def test_numref_with_language_ja(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -412,12 +413,12 @@ def test_latex_obey_numfig_but_math_numfig_false(app, status, warning):
assert '\\usepackage[,numfigreset=2]{sphinx}' in result
@pytest.mark.sphinx('latex')
@pytest.mark.sphinx('latex', testroot='basic')
def test_latex_add_latex_package(app, status, warning):
app.add_latex_package('foo')
app.add_latex_package('bar', 'baz')
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
result = (app.outdir / 'test.tex').text(encoding='utf8')
assert '\\usepackage{foo}' in result
assert '\\usepackage[baz]{bar}' in result
@ -425,7 +426,7 @@ def test_latex_add_latex_package(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-babel')
def test_babel_with_no_language_settings(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -450,7 +451,7 @@ def test_babel_with_no_language_settings(app, status, warning):
confoverrides={'language': 'de'})
def test_babel_with_language_de(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -475,7 +476,7 @@ def test_babel_with_language_de(app, status, warning):
confoverrides={'language': 'ru'})
def test_babel_with_language_ru(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -500,7 +501,7 @@ def test_babel_with_language_ru(app, status, warning):
confoverrides={'language': 'tr'})
def test_babel_with_language_tr(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -525,7 +526,7 @@ def test_babel_with_language_tr(app, status, warning):
confoverrides={'language': 'ja'})
def test_babel_with_language_ja(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -549,7 +550,7 @@ def test_babel_with_language_ja(app, status, warning):
confoverrides={'language': 'unknown'})
def test_babel_with_unknown_language(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -576,7 +577,7 @@ def test_babel_with_unknown_language(app, status, warning):
confoverrides={'language': 'de', 'latex_engine': 'lualatex'})
def test_polyglossia_with_language_de(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -602,7 +603,7 @@ def test_polyglossia_with_language_de(app, status, warning):
confoverrides={'language': 'de-1901', 'latex_engine': 'lualatex'})
def test_polyglossia_with_language_de_1901(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -626,7 +627,7 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
@pytest.mark.sphinx('latex')
def test_footnote(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
result = (app.outdir / 'sphinxtests.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -653,7 +654,7 @@ def test_footnote(app, status, warning):
@pytest.mark.sphinx('latex', testroot='footnotes')
def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -694,7 +695,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
confoverrides={'latex_show_urls': 'inline'})
def test_latex_show_urls_is_inline(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -739,7 +740,7 @@ def test_latex_show_urls_is_inline(app, status, warning):
confoverrides={'latex_show_urls': 'footnote'})
def test_latex_show_urls_is_footnote(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -793,7 +794,7 @@ def test_latex_show_urls_is_footnote(app, status, warning):
confoverrides={'latex_show_urls': 'no'})
def test_latex_show_urls_is_no(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -843,7 +844,7 @@ def test_latex_show_urls_footnote_and_substitutions(app, status, warning):
@pytest.mark.sphinx('latex', testroot='image-in-section')
def test_image_in_section(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -869,7 +870,7 @@ def test_latex_logo_if_not_found(app, status, warning):
@pytest.mark.sphinx('latex', testroot='toctree-maxdepth')
def test_toctree_maxdepth_manual(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -881,12 +882,12 @@ def test_toctree_maxdepth_manual(app, status, warning):
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_documents': [
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
('index', 'python.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'howto'),
]})
def test_toctree_maxdepth_howto(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -900,7 +901,7 @@ def test_toctree_maxdepth_howto(app, status, warning):
confoverrides={'master_doc': 'foo'})
def test_toctree_not_found(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -914,7 +915,7 @@ def test_toctree_not_found(app, status, warning):
confoverrides={'master_doc': 'bar'})
def test_toctree_without_maxdepth(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -927,7 +928,7 @@ def test_toctree_without_maxdepth(app, status, warning):
confoverrides={'master_doc': 'qux'})
def test_toctree_with_deeper_maxdepth(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -940,7 +941,7 @@ def test_toctree_with_deeper_maxdepth(app, status, warning):
confoverrides={'latex_toplevel_sectioning': None})
def test_latex_toplevel_sectioning_is_None(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -952,7 +953,7 @@ def test_latex_toplevel_sectioning_is_None(app, status, warning):
confoverrides={'latex_toplevel_sectioning': 'part'})
def test_latex_toplevel_sectioning_is_part(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -965,12 +966,12 @@ def test_latex_toplevel_sectioning_is_part(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'part',
'latex_documents': [
('index', 'Python.tex', 'Sphinx Tests Documentation',
('index', 'python.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'howto')
]})
def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -984,7 +985,7 @@ def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
confoverrides={'latex_toplevel_sectioning': 'chapter'})
def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -995,12 +996,12 @@ def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'chapter',
'latex_documents': [
('index', 'Python.tex', 'Sphinx Tests Documentation',
('index', 'python.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'howto')
]})
def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -1012,7 +1013,7 @@ def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
confoverrides={'latex_toplevel_sectioning': 'section'})
def test_latex_toplevel_sectioning_is_section(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
@ -1023,11 +1024,11 @@ def test_latex_toplevel_sectioning_is_section(app, status, warning):
@pytest.mark.sphinx('latex', testroot='maxlistdepth')
def test_maxlistdepth_at_ten(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
compile_latex_document(app)
compile_latex_document(app, 'python.tex')
@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
@ -1036,7 +1037,7 @@ def test_maxlistdepth_at_ten(app, status, warning):
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_tabulars(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
tables = {}
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
sectname, content = chap.split('}', 1)
@ -1107,7 +1108,7 @@ def test_latex_table_tabulars(app, status, warning):
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_longtable(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
tables = {}
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
sectname, content = chap.split('}', 1)
@ -1168,7 +1169,7 @@ def test_latex_table_longtable(app, status, warning):
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_complex_tables(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
tables = {}
for chap in re.split(r'\\(?:section|renewcommand){', result)[1:]:
sectname, content = chap.split('}', 1)
@ -1192,7 +1193,7 @@ def test_latex_table_complex_tables(app, status, warning):
confoverrides={'templates_path': ['_mytemplates/latex']})
def test_latex_table_custom_template_caseA(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert 'SALUT LES COPAINS' in result
@ -1200,7 +1201,7 @@ def test_latex_table_custom_template_caseA(app, status, warning):
confoverrides={'templates_path': ['_mytemplates']})
def test_latex_table_custom_template_caseB(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert 'SALUT LES COPAINS' not in result
@ -1208,14 +1209,14 @@ def test_latex_table_custom_template_caseB(app, status, warning):
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_custom_template_caseC(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert 'SALUT LES COPAINS' not in result
@pytest.mark.sphinx('latex', testroot='directives-raw')
def test_latex_raw_directive(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
# standard case
assert 'standalone raw directive (HTML)' not in result
@ -1231,7 +1232,7 @@ def test_latex_raw_directive(app, status, warning):
def test_latex_remote_images(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert '\\sphinxincludegraphics{{python-logo}.png}' in result
assert (app.outdir / 'python-logo.png').exists()
assert '\\sphinxincludegraphics{{NOT_EXIST}.PNG}' not in result
@ -1243,7 +1244,7 @@ def test_latex_remote_images(app, status, warning):
def test_latex_index(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert ('A \\index{famous@\\spxentry{famous}}famous '
'\\index{equation@\\spxentry{equation}}equation:\n' in result)
assert ('\n\\index{Einstein@\\spxentry{Einstein}}'
@ -1257,7 +1258,7 @@ def test_latex_index(app, status, warning):
def test_latex_equations(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
expected = (app.srcdir / 'expects' / 'latex-equations.tex').text().strip()
assert expected in result
@ -1267,7 +1268,7 @@ def test_latex_equations(app, status, warning):
def test_latex_image_in_parsed_literal(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert ('{\\sphinxunactivateextrasandspace \\raisebox{-0.5\\height}'
'{\\scalebox{2.000000}{\\sphinxincludegraphics[height=1cm]{{pic}.png}}}'
'}AFTER') in result
@ -1277,7 +1278,7 @@ def test_latex_image_in_parsed_literal(app, status, warning):
def test_latex_nested_enumerated_list(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert ('\\def\\theenumi{\\arabic{enumi}}\n'
'\\def\\labelenumi{\\theenumi .}\n'
'\\makeatletter\\def\\p@enumii{\\p@enumi \\theenumi .}\\makeatother\n'
@ -1304,7 +1305,7 @@ def test_latex_nested_enumerated_list(app, status, warning):
def test_latex_thebibliography(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(result)
assert ('\\begin{sphinxthebibliography}{AuthorYe}\n'
'\\bibitem[AuthorYear]{index:authoryear}\n'
@ -1317,7 +1318,7 @@ def test_latex_thebibliography(app, status, warning):
def test_latex_glossary(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert ('\\item[{änhlich\\index{änhlich@\\spxentry{änhlich}|spxpagem}'
r'\phantomsection'
r'\label{\detokenize{index:term-anhlich}}}] \leavevmode' in result)
@ -1341,7 +1342,7 @@ def test_latex_glossary(app, status, warning):
def test_latex_labels(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
# figures
assert (r'\caption{labeled figure}'
@ -1380,3 +1381,15 @@ def test_latex_labels(app, status, warning):
assert ('\\subsection{otherdoc}\n'
r'\label{\detokenize{otherdoc:otherdoc}}'
r'\label{\detokenize{otherdoc::doc}}' in result)
def test_default_latex_documents():
from sphinx.util import texescape
texescape.init()
config = Config({'master_doc': 'index',
'project': u'STASI™ Documentation',
'author': u"Wolfgang Schäuble & G'Beckstein"})
config.init_values()
expected = [('index', 'stasi.tex', u'STASI™ Documentation',
u"Wolfgang Schäuble \\& G'Beckstein", 'manual')]
assert default_latex_documents(config) == expected

View File

@ -321,7 +321,7 @@ def test_code_block_caption_html(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_caption_latex(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text()
latex = (app.outdir / 'python.tex').text()
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}'
link = '\\hyperref[\\detokenize{caption:name-test-rb}]' \
@ -334,7 +334,7 @@ def test_code_block_caption_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_namedlink_latex(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text()
latex = (app.outdir / 'python.tex').text()
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}'
link1 = '\\hyperref[\\detokenize{caption:name-test-rb}]'\
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}'
@ -351,7 +351,7 @@ def test_code_block_namedlink_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_emphasize_latex(app, status, warning):
app.builder.build(['emphasize'])
latex = (app.outdir / 'Python.tex').text().replace('\r\n', '\n')
latex = (app.outdir / 'python.tex').text().replace('\r\n', '\n')
includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26,}}%\n'
assert includes in latex
includes = '\\end{sphinxVerbatim}\n\\sphinxresetverbatimhllines\n'
@ -443,7 +443,7 @@ def test_literal_include_linenos(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_file_whole_of_emptyline(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text().replace('\r\n', '\n')
latex = (app.outdir / 'python.tex').text().replace('\r\n', '\n')
includes = (
'\\begin{sphinxVerbatim}'
'[commandchars=\\\\\\{\\},numbers=left,firstnumber=1,stepnumber=1]\n'
@ -469,7 +469,7 @@ def test_literalinclude_caption_html(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_caption_latex(app, status, warning):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text()
latex = (app.outdir / 'python.tex').text()
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
link = '\\hyperref[\\detokenize{caption:name-test-py}]' \
@ -482,7 +482,7 @@ def test_literalinclude_caption_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_namedlink_latex(app, status, warning):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text()
latex = (app.outdir / 'python.tex').text()
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
link1 = '\\hyperref[\\detokenize{caption:name-test-py}]'\
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}'

View File

@ -200,7 +200,7 @@ def test_autosummary_generate(app, status, warning):
@pytest.mark.sphinx('latex', **default_kw)
def test_autosummary_latex_table_colspec(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
print(status.getvalue())
print(warning.getvalue())
assert r'\begin{longtable}{\X{1}{2}\X{1}{2}}' in result

View File

@ -90,7 +90,7 @@ def test_graphviz_svg_html(app, status, warning):
def test_graphviz_latex(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'SphinxTests.tex').text()
content = (app.outdir / 'python.tex').text()
macro = ('\\\\begin{figure}\\[htbp\\]\n\\\\centering\n\\\\capstart\n\n'
'\\\\sphinxincludegraphics\\[\\]{graphviz-\\w+.pdf}\n'
'\\\\caption{caption of graph}\\\\label{.*}\\\\end{figure}')

View File

@ -18,7 +18,7 @@ import pytest
def test_ext_imgconverter(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'Python.tex').text()
content = (app.outdir / 'python.tex').text()
assert '\\sphinxincludegraphics{{svgimg}.png}' in content
assert not (app.outdir / 'svgimg.svg').exists()
assert (app.outdir / 'svgimg.png').exists()

View File

@ -56,7 +56,7 @@ def test_inheritance_diagram_svg_html(app, status, warning):
def test_inheritance_diagram_latex(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'Python.tex').text()
content = (app.outdir / 'python.tex').text()
pattern = ('\\\\begin{figure}\\[htbp]\n\\\\centering\n\\\\capstart\n\n'
'\\\\sphinxincludegraphics\\[\\]{inheritance-\\w+.pdf}\n'

View File

@ -127,7 +127,7 @@ def test_math_number_all_mathjax(app, status, warning):
def test_math_number_all_latex(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'test.tex').text()
content = (app.outdir / 'python.tex').text()
macro = (r'\\begin{equation\*}\s*'
r'\\begin{split}a\^2\+b\^2=c\^2\\end{split}\s*'
r'\\end{equation\*}')
@ -170,7 +170,7 @@ def test_math_eqref_format_html(app, status, warning):
def test_math_eqref_format_latex(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'test.tex').text()
content = (app.outdir / 'python.tex').text()
macro = (r'Referencing equation Eq.\\ref{equation:math:foo} and '
r'Eq.\\ref{equation:math:foo}.')
assert re.search(macro, content, re.S)

View File

@ -105,7 +105,7 @@ def test_todo_valid_link(app, status, warning):
# Ensure the LaTeX output is built.
app.builder.build_all()
content = (app.outdir / 'TodoTests.tex').text()
content = (app.outdir / 'python.tex').text()
# Look for the link to foo. Note that there are two of them because the
# source document uses todolist twice. We could equally well look for links

View File

@ -119,9 +119,6 @@ def test_quickstart_defaults(tempdir):
assert ns['version'] == '0.1'
assert ns['release'] == '0.1'
assert ns['html_static_path'] == ['_static']
assert ns['latex_documents'] == [
('index', 'SphinxTest.tex', 'Sphinx Test Documentation',
'Georg Brandl', 'manual')]
assert (tempdir / '_static').isdir()
assert (tempdir / '_templates').isdir()
@ -178,9 +175,6 @@ def test_quickstart_all_answers(tempdir):
assert ns['release'] == '2.0.1'
assert ns['todo_include_todos'] is True
assert ns['html_static_path'] == ['.static']
assert ns['latex_documents'] == [
('contents', 'STASI.tex', 'STASI™ Documentation',
'Wolfgang Schäuble \\& G\'Beckstein', 'manual')]
assert (tempdir / 'build').isdir()
assert (tempdir / 'source' / '.static').isdir()
@ -249,7 +243,6 @@ def test_default_filename(tempdir):
assert conffile.isfile()
ns = {}
execfile_(conffile, ns)
assert ns['latex_documents'][0][1] == 'sphinx.tex'
def test_extensions(tempdir):

View File

@ -41,7 +41,7 @@ def test_man_builder(app, status, warning):
def test_latex_builder(app, status, warning):
app.build()
content = (app.outdir / 'test.tex').text()
content = (app.outdir / 'python.tex').text()
assert '\\textendash{} “Sphinx” is a tool that makes it easy …' in content

View File

@ -24,7 +24,7 @@ def test_trim_doctest_flags_html(app, status, warning):
def test_trim_doctest_flags_latex(app, status, warning):
app.build()
result = (app.outdir / 'test.tex').text(encoding='utf8')
result = (app.outdir / 'python.tex').text(encoding='utf8')
assert 'FOO' not in result
assert 'BAR' in result
assert 'BAZ' not in result