Merge branch '2.0'

This commit is contained in:
Takeshi KOMIYA 2019-03-10 17:46:12 +09:00
commit 332dd5d89f
8 changed files with 104 additions and 7 deletions

18
CHANGES
View File

@ -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)
=====================================

View File

@ -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):

View File

@ -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)

View File

@ -467,6 +467,21 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
# type: (nodes.Element) -> None
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

View File

View File

@ -0,0 +1,5 @@
index_on_title
==============
Test for :index:`index` in top level title
------------------------------------------

View File

@ -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)

View File

@ -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",