From 68c90a26f1e4bcf4fd1a738641219e1d6f12664f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 3 Sep 2018 21:18:58 +0900 Subject: [PATCH] quickstart: Simplify generated conf.py (for latex) --- CHANGES | 3 + sphinx/builders/latex/__init__.py | 17 ++- sphinx/templates/quickstart/conf.py_t | 29 ---- .../conf.py | 3 - tests/roots/test-epub-anchor-id/conf.py | 5 - tests/roots/test-ext-graphviz/conf.py | 5 - tests/roots/test-ext-math-simple/conf.py | 3 - tests/roots/test-ext-math/conf.py | 3 - tests/roots/test-ext-todo/conf.py | 5 - tests/roots/test-glossary/conf.py | 3 - tests/roots/test-latex-labels/conf.py | 3 - tests/roots/test-latex-table/conf.py | 3 - tests/roots/test-maxlistdepth/conf.py | 5 - .../roots/test-nested-enumerated-list/conf.py | 3 - tests/roots/test-refonly_bullet_list/conf.py | 4 - tests/roots/test-root/conf.py | 5 - tests/roots/test-smartquotes/conf.py | 3 - tests/roots/test-toctree/conf.py | 3 - tests/roots/test-trim_doctest_flags/conf.py | 4 - tests/roots/test-warnings/conf.py | 4 - tests/test_build_latex.py | 127 ++++++++++-------- tests/test_directive_code.py | 12 +- tests/test_ext_autosummary.py | 2 +- tests/test_ext_graphviz.py | 2 +- tests/test_ext_imgconverter.py | 2 +- tests/test_ext_inheritance_diagram.py | 2 +- tests/test_ext_math.py | 4 +- tests/test_ext_todo.py | 2 +- tests/test_quickstart.py | 7 - tests/test_smartquotes.py | 2 +- tests/test_transforms_post_transforms_code.py | 2 +- 31 files changed, 100 insertions(+), 177 deletions(-) diff --git a/CHANGES b/CHANGES index 289b64856..770b1b314 100644 --- a/CHANGES +++ b/CHANGES @@ -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) diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py index 82aa85295..cc3fc9022 100644 --- a/sphinx/builders/latex/__init__.py +++ b/sphinx/builders/latex/__init__.py @@ -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) diff --git a/sphinx/templates/quickstart/conf.py_t b/sphinx/templates/quickstart/conf.py_t index 90f3113ed..cc22cfdba 100644 --- a/sphinx/templates/quickstart/conf.py_t +++ b/sphinx/templates/quickstart/conf.py_t @@ -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. diff --git a/tests/roots/test-builder-gettext-dont-rebuild-mo/conf.py b/tests/roots/test-builder-gettext-dont-rebuild-mo/conf.py index e274bde80..e69de29bb 100644 --- a/tests/roots/test-builder-gettext-dont-rebuild-mo/conf.py +++ b/tests/roots/test-builder-gettext-dont-rebuild-mo/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-epub-anchor-id/conf.py b/tests/roots/test-epub-anchor-id/conf.py index d1b25bfe5..2a56f1f66 100644 --- a/tests/roots/test-epub-anchor-id/conf.py +++ b/tests/roots/test-epub-anchor-id/conf.py @@ -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") diff --git a/tests/roots/test-ext-graphviz/conf.py b/tests/roots/test-ext-graphviz/conf.py index c14103287..cd0492924 100644 --- a/tests/roots/test-ext-graphviz/conf.py +++ b/tests/roots/test-ext-graphviz/conf.py @@ -1,7 +1,2 @@ extensions = ['sphinx.ext.graphviz'] exclude_patterns = ['_build'] - -latex_documents = [ - ('index', 'SphinxTests.tex', 'Sphinx Tests Documentation', - 'Georg Brandl', 'manual'), -] diff --git a/tests/roots/test-ext-math-simple/conf.py b/tests/roots/test-ext-math-simple/conf.py index ce2464554..e69de29bb 100644 --- a/tests/roots/test-ext-math-simple/conf.py +++ b/tests/roots/test-ext-math-simple/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'Math Extension Testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-ext-math/conf.py b/tests/roots/test-ext-math/conf.py index ce2464554..e69de29bb 100644 --- a/tests/roots/test-ext-math/conf.py +++ b/tests/roots/test-ext-math/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'Math Extension Testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-ext-todo/conf.py b/tests/roots/test-ext-todo/conf.py index e7a15a4df..64b749e7f 100644 --- a/tests/roots/test-ext-todo/conf.py +++ b/tests/roots/test-ext-todo/conf.py @@ -1,6 +1 @@ extensions = ['sphinx.ext.todo'] - -latex_documents = [ - ('index', 'TodoTests.tex', 'Todo Tests Documentation', - 'Robin Banks', 'manual'), -] diff --git a/tests/roots/test-glossary/conf.py b/tests/roots/test-glossary/conf.py index e274bde80..e69de29bb 100644 --- a/tests/roots/test-glossary/conf.py +++ b/tests/roots/test-glossary/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-latex-labels/conf.py b/tests/roots/test-latex-labels/conf.py index e274bde80..e69de29bb 100644 --- a/tests/roots/test-latex-labels/conf.py +++ b/tests/roots/test-latex-labels/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-latex-table/conf.py b/tests/roots/test-latex-table/conf.py index e274bde80..e69de29bb 100644 --- a/tests/roots/test-latex-table/conf.py +++ b/tests/roots/test-latex-table/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-maxlistdepth/conf.py b/tests/roots/test-maxlistdepth/conf.py index 5af61edf1..b04872cea 100644 --- a/tests/roots/test-maxlistdepth/conf.py +++ b/tests/roots/test-maxlistdepth/conf.py @@ -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', } diff --git a/tests/roots/test-nested-enumerated-list/conf.py b/tests/roots/test-nested-enumerated-list/conf.py index e274bde80..e69de29bb 100644 --- a/tests/roots/test-nested-enumerated-list/conf.py +++ b/tests/roots/test-nested-enumerated-list/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-refonly_bullet_list/conf.py b/tests/roots/test-refonly_bullet_list/conf.py index 64f502e9d..bdccf9c5f 100644 --- a/tests/roots/test-refonly_bullet_list/conf.py +++ b/tests/roots/test-refonly_bullet_list/conf.py @@ -1,5 +1 @@ html_compact_lists = False - -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-root/conf.py b/tests/roots/test-root/conf.py index 1213a1448..23e5de4f5 100644 --- a/tests/roots/test-root/conf.py +++ b/tests/roots/test-root/conf.py @@ -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'] diff --git a/tests/roots/test-smartquotes/conf.py b/tests/roots/test-smartquotes/conf.py index e274bde80..e69de29bb 100644 --- a/tests/roots/test-smartquotes/conf.py +++ b/tests/roots/test-smartquotes/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-toctree/conf.py b/tests/roots/test-toctree/conf.py index e274bde80..e69de29bb 100644 --- a/tests/roots/test-toctree/conf.py +++ b/tests/roots/test-toctree/conf.py @@ -1,3 +0,0 @@ -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-trim_doctest_flags/conf.py b/tests/roots/test-trim_doctest_flags/conf.py index 6ec1f73ab..77c725510 100644 --- a/tests/roots/test-trim_doctest_flags/conf.py +++ b/tests/roots/test-trim_doctest_flags/conf.py @@ -1,5 +1 @@ extensions = ['sphinx.ext.doctest'] - -latex_documents = [ - ('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report') -] diff --git a/tests/roots/test-warnings/conf.py b/tests/roots/test-warnings/conf.py index 2107708f1..9d12e2d79 100644 --- a/tests/roots/test-warnings/conf.py +++ b/tests/roots/test-warnings/conf.py @@ -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') -] diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 60ea0b480..8922e3491 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -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 diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py index b5e2341bc..6e60d0e9b 100644 --- a/tests/test_directive_code.py +++ b/tests/test_directive_code.py @@ -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}}' diff --git a/tests/test_ext_autosummary.py b/tests/test_ext_autosummary.py index f071e3a83..e1cbaf274 100644 --- a/tests/test_ext_autosummary.py +++ b/tests/test_ext_autosummary.py @@ -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 diff --git a/tests/test_ext_graphviz.py b/tests/test_ext_graphviz.py index 6524fd5a8..75a8717ea 100644 --- a/tests/test_ext_graphviz.py +++ b/tests/test_ext_graphviz.py @@ -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}') diff --git a/tests/test_ext_imgconverter.py b/tests/test_ext_imgconverter.py index 69977ae7a..2e537d5a5 100644 --- a/tests/test_ext_imgconverter.py +++ b/tests/test_ext_imgconverter.py @@ -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() diff --git a/tests/test_ext_inheritance_diagram.py b/tests/test_ext_inheritance_diagram.py index ecee75fb8..76ef36a17 100644 --- a/tests/test_ext_inheritance_diagram.py +++ b/tests/test_ext_inheritance_diagram.py @@ -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' diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 51fb0e5d9..5cf9262c1 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -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) diff --git a/tests/test_ext_todo.py b/tests/test_ext_todo.py index f95b2e7f7..a6e258347 100644 --- a/tests/test_ext_todo.py +++ b/tests/test_ext_todo.py @@ -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 diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index bcd3cf6e9..10e015fd9 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -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): diff --git a/tests/test_smartquotes.py b/tests/test_smartquotes.py index c7f4052ad..e9dfa7ff1 100644 --- a/tests/test_smartquotes.py +++ b/tests/test_smartquotes.py @@ -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 diff --git a/tests/test_transforms_post_transforms_code.py b/tests/test_transforms_post_transforms_code.py index 39b4ff45b..c70dbd839 100644 --- a/tests/test_transforms_post_transforms_code.py +++ b/tests/test_transforms_post_transforms_code.py @@ -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