diff options
-rw-r--r-- | CHANGES | 18 | ||||
-rw-r--r-- | sphinx/builders/latex/__init__.py | 5 | ||||
-rw-r--r-- | sphinx/builders/latex/transforms.py | 37 | ||||
-rw-r--r-- | sphinx/writers/manpage.py | 15 | ||||
-rw-r--r-- | tests/roots/test-index_on_title/conf.py | 0 | ||||
-rw-r--r-- | tests/roots/test-index_on_title/contents.rst | 5 | ||||
-rw-r--r-- | tests/test_build_latex.py | 10 | ||||
-rw-r--r-- | tests/test_build_manpage.py | 21 |
8 files changed, 104 insertions, 7 deletions
@@ -315,8 +315,7 @@ Testing * Stop to use ``SPHINX_TEST_TEMPDIR`` envvar -Release 1.8.5 (in development) -============================== +Release 1.8.6 (in development) Dependencies ------------ @@ -333,11 +332,22 @@ Features added Bugs fixed ---------- +Testing +-------- + +Release 1.8.5 (released Mar 10, 2019) +===================================== + +Bugs fixed +---------- + * LaTeX: Remove extraneous space after author names on PDF title page (refs: #6004) * #6026: LaTeX: A cross reference to definition list does not work * #6046: LaTeX: ``TypeError`` is raised when invalid latex_elements given * #6067: LaTeX: images having a target are concatenated to next line * #6067: LaTeX: images having a target are not aligned even if specified +* #6149: LaTeX: ``:index:`` role in titles causes ``Use of \@icentercr doesn't + match its definition`` error on latexpdf build * #6019: imgconverter: Including multipage PDF fails * #6047: autodoc: ``autofunction`` emits a warning for method objects * #6028: graphviz: Ensure the graphviz filenames are reproducible @@ -345,9 +355,7 @@ Bugs fixed * #6136: ``:name:`` option for ``math`` directive causes a crash * #6139: intersphinx: ValueError on failure reporting * #6135: changes: Fix UnboundLocalError when any module found - -Testing --------- +* #3859: manpage: code-block captions are not displayed correctly Release 1.8.4 (released Feb 03, 2019) ===================================== diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py index 0c6e1aec3..c2218fd15 100644 --- a/sphinx/builders/latex/__init__.py +++ b/sphinx/builders/latex/__init__.py @@ -19,7 +19,7 @@ from sphinx.builders import Builder from sphinx.builders.latex.transforms import ( BibliographyTransform, CitationReferenceTransform, MathReferenceTransform, FootnoteDocnameUpdater, LaTeXFootnoteTransform, LiteralBlockTransform, - ShowUrlsTransform, DocumentTargetTransform, + ShowUrlsTransform, DocumentTargetTransform, IndexInSectionTitleTransform, ) from sphinx.builders.latex.util import ExtBabel from sphinx.config import ENUM @@ -346,7 +346,8 @@ class LaTeXBuilder(Builder): ShowUrlsTransform, LaTeXFootnoteTransform, LiteralBlockTransform, - DocumentTargetTransform]) + DocumentTargetTransform, + IndexInSectionTitleTransform]) transformer.apply_transforms() def finish(self): diff --git a/sphinx/builders/latex/transforms.py b/sphinx/builders/latex/transforms.py index 1306e7bc1..52d5bc9ea 100644 --- a/sphinx/builders/latex/transforms.py +++ b/sphinx/builders/latex/transforms.py @@ -602,3 +602,40 @@ class DocumentTargetTransform(SphinxTransform): section = node.next_node(nodes.section) if section: section['ids'].append(':doc') # special label for :doc: + + +class IndexInSectionTitleTransform(SphinxTransform): + """Move index nodes in section title to outside of the title. + + LaTeX index macro is not compatible with some handling of section titles + such as uppercasing done on LaTeX side (cf. fncychap handling of ``\\chapter``). + Moving the index node to after the title node fixes that. + + Before:: + + <section> + <title> + blah blah <index entries=[...]/>blah + <paragraph> + blah blah blah + ... + + After:: + + <section> + <title> + blah blah blah + <index entries=[...]/> + <paragraph> + blah blah blah + ... + """ + default_priority = 400 + + def apply(self): + for node in self.document.traverse(nodes.title): + if isinstance(node.parent, nodes.section): + for i, index in enumerate(node.traverse(addnodes.index)): + # move the index node next to the section title + node.remove(index) + node.parent.insert(i + 1, index) diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index f743f64f1..0856ee5ee 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -468,6 +468,21 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator): return self.depart_strong(node) # overwritten: handle section titles better than in 0.6 release + def visit_caption(self, node): + # type: (nodes.Element) -> None + if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): + self.body.append('.sp\n') + else: + super().visit_caption(node) + + def depart_caption(self, node): + # type: (nodes.Element) -> None + if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): + self.body.append('\n') + else: + super().depart_caption(node) + + # overwritten: handle section titles better than in 0.6 release def visit_title(self, node): # type: (nodes.Element) -> None if isinstance(node.parent, addnodes.seealso): diff --git a/tests/roots/test-index_on_title/conf.py b/tests/roots/test-index_on_title/conf.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/roots/test-index_on_title/conf.py diff --git a/tests/roots/test-index_on_title/contents.rst b/tests/roots/test-index_on_title/contents.rst new file mode 100644 index 000000000..8256c42d7 --- /dev/null +++ b/tests/roots/test-index_on_title/contents.rst @@ -0,0 +1,5 @@ +index_on_title +============== + +Test for :index:`index` in top level title +------------------------------------------ diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 7772c9faa..f02394cf1 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -1409,3 +1409,13 @@ def test_includegraphics_oversized(app, status, warning): print(status.getvalue()) print(warning.getvalue()) compile_latex_document(app) + + +@pytest.mark.sphinx('latex', testroot='index_on_title') +def test_index_on_title(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'python.tex').text(encoding='utf8') + 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) diff --git a/tests/test_build_manpage.py b/tests/test_build_manpage.py index 663db8439..17a2f7eb8 100644 --- a/tests/test_build_manpage.py +++ b/tests/test_build_manpage.py @@ -30,6 +30,27 @@ def test_all(app, status, warning): assert 'Footnotes' not in content +@pytest.mark.sphinx('man', testroot='directive-code') +def test_captioned_code_block(app, status, warning): + app.builder.build_all() + content = (app.outdir / 'python.1').text() + + assert ('.sp\n' + 'caption \\fItest\\fP rb\n' + '.INDENT 0.0\n' + '.INDENT 3.5\n' + '.sp\n' + '.nf\n' + '.ft C\n' + 'def ruby?\n' + ' false\n' + 'end\n' + '.ft P\n' + '.fi\n' + '.UNINDENT\n' + '.UNINDENT\n' in content) + + def test_default_man_pages(): config = Config({'project': 'STASI™ Documentation', 'author': "Wolfgang Schäuble & G'Beckstein", |