mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
merge stable to default
This commit is contained in:
commit
8232707a12
6
CHANGES
6
CHANGES
@ -47,6 +47,7 @@ Bugs fixed
|
||||
|
||||
* #2134: Fix figure caption with reference causes latex build error
|
||||
* #2094: Fix rubric with reference not working in Latex
|
||||
* #2147: Fix literalinclude code in latex does not break in pages
|
||||
|
||||
|
||||
Release 1.3.3 (released Dec 2, 2015)
|
||||
@ -103,10 +104,7 @@ Bugs fixed
|
||||
* #1942: Fix a KeyError in websupport.
|
||||
* #1903: Fix strange id generation for glossary terms.
|
||||
* #1796, On py3, automated .mo building cause UnicodeDecodeError
|
||||
* Fix: ``make text`` will crush if a definition list item has more than 1 classifiers as:
|
||||
* #1796: On py3, automated .mo building cause UnicodeDecodeError
|
||||
* ``make text`` will crush if a definition list item has more than 1 classifiers as:
|
||||
* Fixed #1855: make gettext generates broken po file for definition lists with classifier.
|
||||
``term : classifier1 : classifier2``.
|
||||
* #1855: make gettext generates broken po file for definition lists with classifier.
|
||||
* #1869: Fix problems when dealing with files containing non-ASCII characters. Thanks to
|
||||
@ -121,6 +119,8 @@ Bugs fixed
|
||||
* #1994: More supporting non-standard parser (like recommonmark parser) for Translation and
|
||||
WebSupport feature. Now node.rawsource is fall backed to node.astext() during docutils
|
||||
transforming.
|
||||
* #1989: "make blahblah" on Windows indicate help messages for sphinx-build every time.
|
||||
It was caused by wrong make.bat that generated by Sphinx-1.3.0/1.3.1.
|
||||
* On Py2 environment, conf.py that is generated by sphinx-quickstart should have u prefixed
|
||||
config value for 'version' and 'release'.
|
||||
* #2102: On Windows + Py3, using ``|today|`` and non-ASCII date format will raise
|
||||
|
@ -1432,6 +1432,8 @@ These options influence LaTeX output.
|
||||
'floated' into the next page but may be preceded by any other text.
|
||||
If you don't like this behavior, use 'H' which will disable floating
|
||||
and position figures strictly in the order they appear in the source.
|
||||
|
||||
.. versionadded:: 1.3
|
||||
``'footer'``
|
||||
Additional footer content (before the indices), default empty.
|
||||
|
||||
|
@ -525,11 +525,18 @@
|
||||
\fi
|
||||
|
||||
% Define literal-block environment
|
||||
\RequirePackage{float}
|
||||
\floatstyle{plaintop}
|
||||
\RequirePackage{newfloat}
|
||||
\DeclareFloatingEnvironment{literal-block}
|
||||
\ifx\thechapter\undefined
|
||||
\newfloat{literal-block}{htbp}{loc}[section]
|
||||
\SetupFloatingEnvironment{literal-block}{within=section,placement=h}
|
||||
\else
|
||||
\newfloat{literal-block}{htbp}{loc}[chapter]
|
||||
\SetupFloatingEnvironment{literal-block}{within=chapter,placement=h}
|
||||
\fi
|
||||
\floatname{literal-block}{List}
|
||||
\SetupFloatingEnvironment{literal-block}{name=List}
|
||||
% control caption around literal-block
|
||||
\RequirePackage{capt-of}
|
||||
\RequirePackage{needspace}
|
||||
% if the left page space is less than \literalblockneedsapce, insert page-break
|
||||
\newcommand{\literalblockneedspace}{5\baselineskip}
|
||||
% margin before the caption of literal-block
|
||||
\newcommand{\literalblockcaptiontopvspace}{0.5\baselineskip}
|
||||
|
@ -296,6 +296,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.in_production_list = 0
|
||||
self.in_footnote = 0
|
||||
self.in_caption = 0
|
||||
self.in_container_literal_block = 0
|
||||
self.first_document = 1
|
||||
self.this_is_the_title = 1
|
||||
self.literal_whitespace = 0
|
||||
@ -400,7 +401,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
if len(codeblock) == 1:
|
||||
pass # FIXME
|
||||
else:
|
||||
ret.append('\\floatname{literal-block}{%s}\n' %
|
||||
ret.append('\\SetupFloatingEnvironment{literal-block}{name=%s}\n' %
|
||||
text_type(codeblock[0]).translate(tex_escape_map))
|
||||
if table[1]:
|
||||
pass # FIXME
|
||||
@ -749,8 +750,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
raise nodes.SkipNode
|
||||
self.body.append('\\paragraph{')
|
||||
self.context.append('}\n')
|
||||
self.in_title = 1
|
||||
|
||||
def depart_rubric(self, node):
|
||||
self.in_title = 0
|
||||
self.body.append(self.context.pop())
|
||||
|
||||
def visit_footnote(self, node):
|
||||
@ -1179,7 +1182,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
options = ''
|
||||
if include_graphics_options:
|
||||
options = '[%s]' % ','.join(include_graphics_options)
|
||||
self.body.append('\\includegraphics%s{%s}' % (options, uri))
|
||||
base, ext = path.splitext(uri)
|
||||
self.body.append('\\includegraphics%s{{%s}%s}' % (options, base, ext))
|
||||
self.body.extend(post)
|
||||
|
||||
def depart_image(self, node):
|
||||
@ -1220,6 +1224,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
|
||||
def visit_caption(self, node):
|
||||
self.in_caption += 1
|
||||
if self.in_container_literal_block:
|
||||
self.body.append('\\needspace{\\literalblockneedspace}')
|
||||
self.body.append('\\vspace{\\literalblockcaptiontopvspace}')
|
||||
self.body.append('\\captionof{literal-block}{')
|
||||
return
|
||||
self.body.append('\\caption{')
|
||||
|
||||
def depart_caption(self, node):
|
||||
@ -1381,8 +1390,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_reference(self, node):
|
||||
if not self.in_title:
|
||||
for id in node.get('ids'):
|
||||
self.body += self.hypertarget(id, anchor=True)
|
||||
anchor = not self.in_caption
|
||||
self.body += self.hypertarget(id, anchor=anchor)
|
||||
uri = node.get('refuri', '')
|
||||
if not uri and node.get('refid'):
|
||||
uri = '%' + self.curfilestack[-1] + '#' + node['refid']
|
||||
@ -1770,17 +1781,19 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
|
||||
def visit_container(self, node):
|
||||
if node.get('literal_block'):
|
||||
self.in_container_literal_block += 1
|
||||
ids = ''
|
||||
for id in self.next_literal_ids:
|
||||
ids += self.hypertarget(id, anchor=False)
|
||||
if node['ids']:
|
||||
ids += self.hypertarget(node['ids'][0])
|
||||
self.next_literal_ids.clear()
|
||||
self.body.append('\n\\begin{literal-block}\n')
|
||||
self.context.append(ids + '\n\\end{literal-block}\n')
|
||||
self.body.append('\n')
|
||||
self.context.append(ids + '\n')
|
||||
|
||||
def depart_container(self, node):
|
||||
if node.get('literal_block'):
|
||||
self.in_container_literal_block -= 1
|
||||
self.body.append(self.context.pop())
|
||||
|
||||
def visit_decoration(self, node):
|
||||
|
@ -26,3 +26,6 @@ Sphinx image handling
|
||||
|
||||
.. an SVG image (for HTML at least)
|
||||
.. image:: svgimg.*
|
||||
|
||||
.. an image with more than 1 dot in its file name
|
||||
.. image:: img.foo.png
|
||||
|
BIN
tests/root/img.foo.png
Normal file
BIN
tests/root/img.foo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
4
tests/roots/test-references-in-caption/conf.py
Normal file
4
tests/roots/test-references-in-caption/conf.py
Normal file
@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
||||
html_theme = 'classic'
|
22
tests/roots/test-references-in-caption/index.rst
Normal file
22
tests/roots/test-references-in-caption/index.rst
Normal file
@ -0,0 +1,22 @@
|
||||
==============
|
||||
test-reference
|
||||
==============
|
||||
|
||||
The section with a reference to [AuthorYear]_
|
||||
=============================================
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
This is the figure caption with a reference to [AuthorYear]_.
|
||||
|
||||
.. list-table:: The table title with a reference to [AuthorYear]_
|
||||
:header-rows: 1
|
||||
|
||||
* - Header1
|
||||
- Header2
|
||||
* - Content
|
||||
- Content
|
||||
|
||||
.. rubric:: The rubric title with a reference to [AuthorYear]_
|
||||
|
||||
.. [AuthorYear] Author, Title, Year
|
BIN
tests/roots/test-references-in-caption/rimg.png
Normal file
BIN
tests/roots/test-references-in-caption/rimg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 218 B |
@ -168,7 +168,7 @@ def test_numref(app, status, warning):
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig. }}' in result
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table }}' in result
|
||||
assert '\\floatname{literal-block}{Listing }' in result
|
||||
assert '\\SetupFloatingEnvironment{literal-block}{name=Listing }' in result
|
||||
assert '\\hyperref[index:fig1]{Fig. \\ref{index:fig1}}' in result
|
||||
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
||||
assert '\\hyperref[index:table-1]{Table \\ref{index:table-1}}' in result
|
||||
@ -190,7 +190,7 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Figure:}}' in result
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Tab\\_}}' in result
|
||||
assert '\\floatname{literal-block}{Code-}' in result
|
||||
assert '\\SetupFloatingEnvironment{literal-block}{name=Code-}' in result
|
||||
assert '\\ref{index:fig1}' in result
|
||||
assert '\\ref{baz:fig22}' in result
|
||||
assert '\\ref{index:table-1}' in result
|
||||
@ -220,7 +220,7 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
assert '\\def\\fnum@figure{\\figurename\\thefigure.}' in result
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Tab\\_}}' in result
|
||||
assert '\\def\\fnum@table{\\tablename\\thetable:}' in result
|
||||
assert '\\floatname{literal-block}{Code-}' in result
|
||||
assert '\\SetupFloatingEnvironment{literal-block}{name=Code-}' in result
|
||||
assert '\\hyperref[index:fig1]{Figure:\\ref{index:fig1}.}' in result
|
||||
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
||||
assert '\\hyperref[index:table-1]{Tab\\_\\ref{index:table-1}:}' in result
|
||||
@ -239,7 +239,7 @@ def test_numref_with_language_el(app, status, warning):
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsgreek{\\renewcommand{\\figurename}{Fig. }}' in result
|
||||
assert '\\addto\\captionsgreek{\\renewcommand{\\tablename}{Table }}' in result
|
||||
assert '\\floatname{literal-block}{Listing }' in result
|
||||
assert '\\SetupFloatingEnvironment{literal-block}{name=Listing }' in result
|
||||
assert '\\hyperref[index:fig1]{Fig. \\ref{index:fig1}}' in result
|
||||
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
||||
assert '\\hyperref[index:table-1]{Table \\ref{index:table-1}}' in result
|
||||
@ -258,7 +258,7 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
print(warning.getvalue())
|
||||
assert u'\\renewcommand{\\figurename}{\u56f3 }' in result
|
||||
assert '\\renewcommand{\\tablename}{TABLE }' in result
|
||||
assert '\\floatname{literal-block}{LIST }' in result
|
||||
assert '\\SetupFloatingEnvironment{literal-block}{name=LIST }' in result
|
||||
assert u'\\hyperref[index:fig1]{\u56f3 \\ref{index:fig1}}' in result
|
||||
assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result
|
||||
assert '\\hyperref[index:table-1]{TABLE \\ref{index:table-1}}' in result
|
||||
@ -318,3 +318,17 @@ def test_footnote(app, status, warning):
|
||||
assert ('\\end{threeparttable}\n\n'
|
||||
'\\footnotetext[4]{\nfootnotes in table caption\n}'
|
||||
'\\footnotetext[5]{\nfootnotes in table\n}' in result)
|
||||
|
||||
|
||||
@with_app(buildername='latex', testroot='references-in-caption')
|
||||
def test_reference_in_caption(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('\\caption{This is the figure caption with a reference to \\label{index:id2}'
|
||||
'{\\hyperref[index:authoryear]{\\emph{{[}AuthorYear{]}}}}.}' in result)
|
||||
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
|
||||
assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result
|
||||
assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result
|
||||
|
@ -64,7 +64,7 @@ def test_code_block_caption_html(app, status, warning):
|
||||
def test_code_block_caption_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||
caption = '\\caption{caption \\emph{test} rb}'
|
||||
caption = '\\captionof{literal-block}{caption \\emph{test} rb}'
|
||||
assert caption in latex
|
||||
|
||||
|
||||
@ -205,5 +205,5 @@ def test_literalinclude_caption_html(app, status, warning):
|
||||
def test_literalinclude_caption_latex(app, status, warning):
|
||||
app.builder.build('index')
|
||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||
caption = '\\caption{caption \\textbf{test} py}'
|
||||
caption = '\\captionof{literal-block}{caption \\textbf{test} py}'
|
||||
assert caption in latex
|
||||
|
@ -63,9 +63,10 @@ def test_images():
|
||||
image_uri_message = remove_unicode_literals(image_uri_message)
|
||||
assert image_uri_message in app._warning.content[-1]
|
||||
assert set(htmlbuilder.images.keys()) == \
|
||||
set(['subdir/img.png', 'img.png', 'subdir/simg.png', 'svgimg.svg'])
|
||||
set(['subdir/img.png', 'img.png', 'subdir/simg.png', 'svgimg.svg',
|
||||
'img.foo.png'])
|
||||
assert set(htmlbuilder.images.values()) == \
|
||||
set(['img.png', 'img1.png', 'simg.png', 'svgimg.svg'])
|
||||
set(['img.png', 'img1.png', 'simg.png', 'svgimg.svg', 'img.foo.png'])
|
||||
|
||||
app._warning.reset()
|
||||
latexbuilder = LaTeXBuilder(app)
|
||||
@ -73,9 +74,10 @@ def test_images():
|
||||
assert image_uri_message in app._warning.content[-1]
|
||||
assert set(latexbuilder.images.keys()) == \
|
||||
set(['subdir/img.png', 'subdir/simg.png', 'img.png', 'img.pdf',
|
||||
'svgimg.pdf'])
|
||||
'svgimg.pdf', 'img.foo.png'])
|
||||
assert set(latexbuilder.images.values()) == \
|
||||
set(['img.pdf', 'img.png', 'img1.png', 'simg.png', 'svgimg.pdf'])
|
||||
set(['img.pdf', 'img.png', 'img1.png', 'simg.png',
|
||||
'svgimg.pdf', 'img.foo.png'])
|
||||
|
||||
|
||||
def test_second_update():
|
||||
|
Loading…
Reference in New Issue
Block a user