Merge branch 'stable'

This commit is contained in:
Takeshi KOMIYA 2017-01-16 01:31:57 +09:00
commit e6cd347f6c
17 changed files with 135 additions and 91 deletions

11
CHANGES
View File

@ -92,7 +92,16 @@ Bugs fixed
unserializable exception
* #3315: Bibliography crashes on latex build with docclass 'memoir'
* #3328: Could not refer rubric implicitly
* #3329: emit warnings if po file is invalid and can't read it. Also writing mo too.
* #3329: emit warnings if po file is invalid and can't read it. Also writing mo too
* #3337: Ugly rendering of definition list term's classifier
* #3335: gettext does not extract field_name of a field in a field_list
* #2952: C++, fix refs to operator() functions.
* Fix Unicode super- and subscript digits in :rst:dir:`code-block` and
:dudir:`parsed-literal` LaTeX output (ref #3342)
* LaTeX writer: leave ``"`` character inside :dudir:`parsed-literal` as is
(ref #3341)
* #3234: intersphinx failed for encoded inventories
* #3158: too much space after captions in PDF output
Release 1.5.1 (released Dec 13, 2016)

View File

@ -2,6 +2,8 @@ include README.rst
include LICENSE
include AUTHORS
include CHANGES
include CHANGES.old
include CONTRIBUTING.rst
include EXAMPLES
include TODO
@ -12,11 +14,15 @@ include sphinx-autogen.py
include sphinx-build.py
include sphinx-quickstart.py
include sphinx-apidoc.py
include test-reqs.txt
include tox.ini
include sphinx/locale/.tx/config
recursive-include sphinx/templates *
recursive-include sphinx/texinputs *
recursive-include sphinx/themes *
recursive-include sphinx/locale *
recursive-include sphinx/pycode/pgen2 *.c *.pyx
recursive-include sphinx/locale *.js *.pot *.po *.mo
recursive-include sphinx/search/non-minified-js *.js
recursive-include sphinx/ext/autosummary/templates *
recursive-include tests *
@ -25,3 +31,4 @@ include sphinx/pycode/Grammar-py*
recursive-include doc *
prune doc/_build
prune sphinx/locale/.tx

View File

@ -54,11 +54,18 @@ clean-patchfiles:
clean-backupfiles:
find . -name '*~' -exec rm -f {} +
find . -name '*.bak' -exec rm -f {} +
find . -name '*.swp' -exec rm -f {} +
find . -name '*.swo' -exec rm -f {} +
clean-generated:
find . -name '.DS_Store' -exec rm -f {} +
rm -f doc/_build/
rm -f sphinx/pycode/*.pickle
rm -f utils/*3.py*
rm -f utils/regression_test.js
clean-testfiles:
rm -rf tests/.coverage
rm -rf tests/build
rm -rf .tox/
rm -rf .cache/

View File

@ -94,14 +94,14 @@ This section describe a easy way to translate with sphinx-intl.
$ make gettext
As a result, many pot files are generated under ``_build/locale``
As a result, many pot files are generated under ``_build/gettext``
directory.
#. Setup/Update your `locale_dir`:
.. code-block:: console
$ sphinx-intl update -p _build/locale -l de -l ja
$ sphinx-intl update -p _build/gettext -l de -l ja
Done. You got these directories that contain po files:

View File

@ -26,4 +26,4 @@ universal = 1
[flake8]
max-line-length = 95
ignore = E116,E241,E251
exclude = .git,.tox,tests/*,build/*,sphinx/search/*,sphinx/pycode/pgen2/*,doc/ext/example*.py
exclude = .git,.tox,tests/*,build/*,sphinx/search/*,sphinx/pycode/pgen2/*,doc/ext/example*.py

View File

@ -4411,6 +4411,9 @@ class DefinitionParser(object):
# type: () -> ASTNamespace
templatePrefix = self._parse_template_declaration_prefix(objectType="xref")
name = self._parse_nested_name()
# if there are '()' left, just skip them
self.skip_ws()
self.skip_string('()')
templatePrefix = self._check_template_consistency(name, templatePrefix,
fullSpecShorthand=True)
res = ASTNamespace(name, templatePrefix)
@ -4884,10 +4887,12 @@ class CPPDomain(Domain):
if emitWarnings:
logger.warning(msg, location=node)
warner = Warner()
# add parens again for those that could be functions
if typ == 'any' or typ == 'func':
target += '()'
parser = DefinitionParser(target, warner, env.config)
try:
ast = parser.parse_xref_object()
parser.skip_ws()
parser.assert_end()
except DefinitionError as e:
warner.warn('Unparseable C++ cross-reference: %r\n%s'
@ -4947,11 +4952,26 @@ class CPPDomain(Domain):
name = text_type(fullNestedName).lstrip(':')
docname = s.docname
assert docname
if typ == 'any' and declaration.objectType == 'function':
if env.config.add_function_parentheses:
if not node['refexplicit']:
title = contnode.pop(0).astext()
contnode += nodes.Text(title + '()')
# If it's operator(), we need to add '()' if explicit function parens
# are requested. Then the Sphinx machinery will add another pair.
# Also, if it's an 'any' ref that resolves to a function, we need to add
# parens as well.
addParen = 0
if not node['refexplicit'] and declaration.objectType == 'function':
# this is just the normal haxing for 'any' roles
if env.config.add_function_parentheses and typ == 'any':
addParen += 1
# and now this stuff for operator()
if (env.config.add_function_parentheses and typ == 'function' and
contnode[-1].astext().endswith('operator()')):
addParen += 1
if ((typ == 'any' or typ == 'function') and
contnode[-1].astext().endswith('operator') and
name.endswith('operator()')):
addParen += 1
if addParen > 0:
title = contnode.pop(0).astext()
contnode += nodes.Text(title + '()' * addParen)
return make_refnode(builder, fromdocname, docname,
declaration.get_newest_id(), contnode, name
), declaration.objectType

View File

@ -29,6 +29,7 @@ from __future__ import print_function
import time
import zlib
import codecs
import functools
import posixpath
from os import path
import re
@ -185,6 +186,9 @@ def _read_from_url(url, config=None):
r = requests.get(url, stream=True, config=config, timeout=config.intersphinx_timeout)
r.raise_for_status()
r.raw.url = r.url
# decode content-body based on the header.
# ref: https://github.com/kennethreitz/requests/issues/2155
r.raw.read = functools.partial(r.raw.read, decode_content=True)
return r.raw

View File

View File

@ -75,17 +75,12 @@ def apply_source_workaround(node):
if node.source and node.rawsource:
return
# workaround: docutils-0.10.0 or older's nodes.caption for nodes.figure
# and nodes.title for nodes.admonition doesn't have source, line.
# this issue was filed to Docutils tracker:
# sf.net/tracker/?func=detail&aid=3599485&group_id=38414&atid=422032
# sourceforge.net/p/docutils/patches/108/
# workaround: some docutils nodes doesn't have source, line.
if (isinstance(node, (
nodes.caption,
nodes.title,
nodes.rubric,
nodes.line,
nodes.image,
nodes.rubric, # #1305 rubric directive
nodes.line, # #1477 line node
nodes.image, # #3093 image directive in substitution
nodes.field_name, # #3335 field list syntax
))):
node.source = find_source_node(node)
node.line = 0 # need fix docutils to get `node.line`

View File

@ -48,26 +48,26 @@ tex_replacements = [
('', r'\textbar{}'),
('', r'e'),
('', r'i'),
('', r'$^\text{0}$'),
('¹', r'$^\text{1}$'),
('²', r'$^\text{2}$'),
('³', r'$^\text{3}$'),
('', r'$^\text{4}$'),
('', r'$^\text{5}$'),
('', r'$^\text{6}$'),
('', r'$^\text{7}$'),
('', r'$^\text{8}$'),
('', r'$^\text{9}$'),
('', r'$_\text{0}$'),
('', r'$_\text{1}$'),
('', r'$_\text{2}$'),
('', r'$_\text{3}$'),
('', r'$_\text{4}$'),
('', r'$_\text{5}$'),
('', r'$_\text{6}$'),
('', r'$_\text{7}$'),
('', r'$_\text{8}$'),
('', r'$_\text{9}$'),
('', r'\(\sp{\text{0}}\)'),
('¹', r'\(\sp{\text{1}}\)'),
('²', r'\(\sp{\text{2}}\)'),
('³', r'\(\sp{\text{3}}\)'),
('', r'\(\sp{\text{4}}\)'),
('', r'\(\sp{\text{5}}\)'),
('', r'\(\sp{\text{6}}\)'),
('', r'\(\sp{\text{7}}\)'),
('', r'\(\sp{\text{8}}\)'),
('', r'\(\sp{\text{9}}\)'),
('', r'\(\sb{\text{0}}\)'),
('', r'\(\sb{\text{1}}\)'),
('', r'\(\sb{\text{2}}\)'),
('', r'\(\sb{\text{3}}\)'),
('', r'\(\sb{\text{4}}\)'),
('', r'\(\sb{\text{5}}\)'),
('', r'\(\sb{\text{6}}\)'),
('', r'\(\sb{\text{7}}\)'),
('', r'\(\sb{\text{8}}\)'),
('', r'\(\sb{\text{9}}\)'),
# map Greek alphabet
('α', r'\(\alpha\)'),
('β', r'\(\beta\)'),

View File

@ -698,24 +698,6 @@ class HTMLTranslator(BaseTranslator):
def depart_abbreviation(self, node):
self.body.append('</abbr>')
# overwritten (but not changed) to keep pair of visit/depart_term
def visit_term(self, node):
self.body.append(self.starttag(node, 'dt', ''))
# overwritten to add '</dt>' in 'depart_term' state.
def depart_term(self, node):
self.body.append('</dt>\n')
# overwritten to do not add '</dt>' in 'visit_definition' state.
def visit_definition(self, node):
self.generate_targets_for_listing(node)
self.body.append(self.starttag(node, 'dd', ''))
self.set_first_last(node)
# overwritten (but not changed) to keep pair of visit/depart_definition
def depart_definition(self, node):
self.body.append('</dd>\n')
def visit_manpage(self, node):
return self.visit_literal_emphasis(node)

View File

@ -379,6 +379,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.this_is_the_title = 1
self.literal_whitespace = 0
self.no_contractions = 0
self.in_parsed_literal = 0
self.compact_list = 0
self.first_param = 0
self.remember_multirow = {} # type: Dict[int, int]
@ -652,34 +653,34 @@ class LaTeXTranslator(nodes.NodeVisitor):
figure = self.builder.config.numfig_format['figure'].split('%s', 1)
if len(figure) == 1:
ret.append('\\def\\fnum@figure{%s}\n' %
escape_abbr(text_type(figure[0]).translate(tex_escape_map)))
text_type(figure[0]).strip().translate(tex_escape_map))
else:
definition = escape_abbr(text_type(figure[0]).translate(tex_escape_map))
definition = text_type(figure[0]).strip().translate(tex_escape_map)
ret.append(self.babel_renewcommand('\\figurename', definition))
if figure[1]:
ret.append('\\makeatletter\n')
ret.append('\\def\\fnum@figure{\\figurename\\thefigure%s}\n' %
escape_abbr(text_type(figure[1]).translate(tex_escape_map)))
text_type(figure[1]).strip().translate(tex_escape_map))
ret.append('\\makeatother\n')
table = self.builder.config.numfig_format['table'].split('%s', 1)
if len(table) == 1:
ret.append('\\def\\fnum@table{%s}\n' %
escape_abbr(text_type(table[0]).translate(tex_escape_map)))
text_type(table[0]).strip().translate(tex_escape_map))
else:
definition = escape_abbr(text_type(table[0]).translate(tex_escape_map))
definition = text_type(table[0]).strip().translate(tex_escape_map)
ret.append(self.babel_renewcommand('\\tablename', definition))
if table[1]:
ret.append('\\makeatletter\n')
ret.append('\\def\\fnum@table{\\tablename\\thetable%s}\n' %
escape_abbr(text_type(table[1]).translate(tex_escape_map)))
text_type(table[1]).strip().translate(tex_escape_map))
ret.append('\\makeatother\n')
codeblock = self.builder.config.numfig_format['code-block'].split('%s', 1)
if len(codeblock) == 1:
pass # FIXME
else:
definition = escape_abbr(text_type(codeblock[0]).translate(tex_escape_map))
definition = text_type(codeblock[0]).strip().translate(tex_escape_map)
ret.append(self.babel_renewcommand('\\literalblockname', definition))
if codeblock[1]:
pass # FIXME
@ -2112,6 +2113,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
# type: (nodes.Node) -> None
if node.rawsource != node.astext():
# most probably a parsed-literal block -- don't highlight
self.in_parsed_literal += 1
self.body.append('\\begin{alltt}\n')
else:
ids = '' # type: unicode
@ -2173,6 +2175,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def depart_literal_block(self, node):
# type: (nodes.Node) -> None
self.body.append('\n\\end{alltt}\n')
self.in_parsed_literal -= 1
visit_doctest_block = visit_literal_block
depart_doctest_block = depart_literal_block
@ -2416,7 +2419,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_Text(self, node):
# type: (nodes.Node) -> None
text = self.encode(node.astext())
if not self.no_contractions:
if not self.no_contractions and not self.in_parsed_literal:
text = educate_quotes_latex(text)
self.body.append(text)

View File

@ -11,3 +11,7 @@ any role
* ref function with parens :cpp:any:`paren_2()`
* ref function without parens, explicit title :cpp:any:`paren_3_title <paren_3>`
* ref function with parens, explicit title :cpp:any:`paren_4_title <paren_4()>`
* ref op call without parens :cpp:any:`paren_5::operator()`
* ref op call with parens :cpp:any:`paren_6::operator()()`
* ref op call without parens, explicit title :cpp:any:`paren_7_title <paren_7::operator()>`
* ref op call with parens, explicit title :cpp:any:`paren_8_title <paren_8::operator()()>`

View File

@ -38,9 +38,10 @@ directives
.. cpp:function:: void paren_1(int, float)
.. cpp:function:: void paren_2(int, float)
.. cpp:function:: void paren_3(int, float)
.. cpp:function:: void paren_4(int, float)
.. cpp:function:: void paren_5::operator()(int)
.. cpp:function:: void paren_6::operator()(int)
.. cpp:function:: void paren_7::operator()(int)
.. cpp:function:: void paren_8::operator()(int)

View File

@ -11,3 +11,7 @@ roles
* ref function with parens :cpp:func:`paren_2()`
* ref function without parens, explicit title :cpp:func:`paren_3_title <paren_3>`
* ref function with parens, explicit title :cpp:func:`paren_4_title <paren_4()>`
* ref op call without parens :cpp:func:`paren_5::operator()`
* ref op call with parens :cpp:func:`paren_6::operator()()`
* ref op call without parens, explicit title :cpp:func:`paren_7_title <paren_7::operator()>`
* ref op call with parens, explicit title :cpp:func:`paren_8_title <paren_8::operator()()>`

View File

@ -178,9 +178,9 @@ def test_numref(app, status, warning):
print(result)
print(status.getvalue())
print(warning.getvalue())
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.\\@ }}' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table }}' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Listing }}' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table}}' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Listing}}' in result
assert ('\\hyperref[\\detokenize{index:fig1}]'
'{Fig.\\@ \\ref{\\detokenize{index:fig1}}}') in result
assert ('\\hyperref[\\detokenize{baz:fig22}]'
@ -261,7 +261,7 @@ def test_numref_with_prefix2(app, status, warning):
print(status.getvalue())
print(warning.getvalue())
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Figure:}}' in result
assert '\\def\\fnum@figure{\\figurename\\thefigure.\\@}' in result
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 '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Code-}}' in result
@ -296,9 +296,9 @@ def test_numref_with_language_ja(app, status, warning):
print(result)
print(status.getvalue())
print(warning.getvalue())
assert u'\\renewcommand{\\figurename}{\u56f3 }' in result
assert '\\renewcommand{\\tablename}{TABLE }' in result
assert '\\renewcommand{\\literalblockname}{LIST }' in result
assert u'\\renewcommand{\\figurename}{\u56f3}' in result
assert '\\renewcommand{\\tablename}{TABLE}' in result
assert '\\renewcommand{\\literalblockname}{LIST}' in result
assert (u'\\hyperref[\\detokenize{index:fig1}]'
u'{\u56f3 \\ref{\\detokenize{index:fig1}}}') in result
assert ('\\hyperref[\\detokenize{baz:fig22}]'
@ -344,8 +344,8 @@ def test_babel_with_no_language_settings(app, status, warning):
assert '\\usepackage[Bjarne]{fncychap}' in result
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
in result)
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
assert '\\shorthandoff' not in result
@ -365,8 +365,8 @@ def test_babel_with_language_de(app, status, warning):
assert '\\usepackage[Sonny]{fncychap}' in result
assert ('\\addto\\captionsngerman{\\renewcommand{\\contentsname}{Table of content}}\n'
in result)
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.}}\n' in result
assert '\\addto\\extrasngerman{\\def\\pageautorefname{Seite}}\n' in result
assert '\\shorthandoff{"}' in result
@ -386,8 +386,8 @@ def test_babel_with_language_ru(app, status, warning):
assert '\\usepackage[Sonny]{fncychap}' in result
assert ('\\addto\\captionsrussian{\\renewcommand{\\contentsname}{Table of content}}\n'
in result)
assert '\\addto\\captionsrussian{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
assert '\\addto\\captionsrussian{\\renewcommand{\\figurename}{Fig.}}\n' in result
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.}}\n' in result
assert (u'\\addto\\extrasrussian{\\def\\pageautorefname'
u'{\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430}}\n' in result)
assert '\\shorthandoff' not in result
@ -408,8 +408,8 @@ def test_babel_with_language_tr(app, status, warning):
assert '\\usepackage[Sonny]{fncychap}' in result
assert ('\\addto\\captionsturkish{\\renewcommand{\\contentsname}{Table of content}}\n'
in result)
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig.}}\n' in result
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.}}\n' in result
assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result
assert '\\shorthandoff{=}' in result
@ -428,8 +428,8 @@ def test_babel_with_language_ja(app, status, warning):
assert '\\usepackage{times}' in result
assert '\\usepackage[Sonny]{fncychap}' not in result
assert '\\renewcommand{\\contentsname}{Table of content}\n' in result
assert '\\renewcommand{\\figurename}{Fig.\\@ }\n' in result
assert '\\renewcommand{\\tablename}{Table.\\@ }\n' in result
assert '\\renewcommand{\\figurename}{Fig.}\n' in result
assert '\\renewcommand{\\tablename}{Table.}\n' in result
assert u'\\def\\pageautorefname{ページ}\n' in result
assert '\\shorthandoff' not in result
@ -449,8 +449,8 @@ def test_babel_with_unknown_language(app, status, warning):
assert '\\usepackage[Sonny]{fncychap}' in result
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
in result)
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.\\@ }}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.\\@ }}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
assert '\\shorthandoff' not in result

View File

@ -524,7 +524,11 @@ def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, war
('ref function without parens ', 'paren_1\(\)'),
('ref function with parens ', 'paren_2\(\)'),
('ref function without parens, explicit title ', 'paren_3_title'),
('ref function with parens, explicit title ', 'paren_4_title')
('ref function with parens, explicit title ', 'paren_4_title'),
('ref op call without parens ', 'paren_5::operator\(\)\(\)'),
('ref op call with parens ', 'paren_6::operator\(\)\(\)'),
('ref op call without parens, explicit title ', 'paren_7_title'),
('ref op call with parens, explicit title ', 'paren_8_title')
]
f = 'roles.html'
@ -562,7 +566,11 @@ def test_build_domain_cpp_with_add_function_parentheses_is_False(app, status, wa
('ref function without parens ', 'paren_1'),
('ref function with parens ', 'paren_2'),
('ref function without parens, explicit title ', 'paren_3_title'),
('ref function with parens, explicit title ', 'paren_4_title')
('ref function with parens, explicit title ', 'paren_4_title'),
('ref op call without parens ', 'paren_5::operator\(\)'),
('ref op call with parens ', 'paren_6::operator\(\)'),
('ref op call without parens, explicit title ', 'paren_7_title'),
('ref op call with parens, explicit title ', 'paren_8_title')
]
f = 'roles.html'