Merge branch '1.7' into 4978_incorrect_shorthandoff_for_brazil

This commit is contained in:
Takeshi KOMIYA 2018-05-19 14:04:22 +09:00 committed by GitHub
commit 58f11980cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 13 deletions

View File

@ -25,7 +25,11 @@ Bugs fixed
* #4962: C++, raised TypeError on duplicate declaration.
* #4825: C++, properly parse expr roles and give better error messages when
(escaped) line breaks are present.
* C++, properly use ``desc_addname`` nodes for prefixes of names.
* #4915, #4916: links on search page are broken when using dirhtml builder
* #4969: autodoc: constructor method should not have return annotation
* latex: deeply nested enumerated list which is beginning with non-1 causes
LaTeX engine crashed
* #4978: latex: shorthandoff is not set up for Brazil locale
Testing

View File

@ -185,7 +185,7 @@ class Epub3Builder(_epub_base.EpubBuilder):
navstack[-1].children.append(navpoint)
navstack.append(navpoint)
else:
raise
raise RuntimeError('Should never reach here. It might be a bug.')
return navstack[0].children

View File

@ -1965,26 +1965,34 @@ class ASTNestedName(ASTBase):
prefix = '' # type: unicode
first = True
names = self.names[:-1] if mode == 'lastIsName' else self.names
# If lastIsName, then wrap all of the prefix in a desc_addname,
# else append directly to signode.
# NOTE: Breathe relies on the prefix being in the desc_addname node,
# so it can remove it in inner declarations.
dest = signode
if mode == 'lastIsName':
dest = addnodes.desc_addname()
for i in range(len(names)):
name = names[i]
template = self.templates[i]
if not first:
signode += nodes.Text('::')
dest += nodes.Text('::')
prefix += '::'
if template:
signode += nodes.Text("template ")
dest += nodes.Text("template ")
first = False
if name != '':
if (name.templateArgs and # type: ignore
iTemplateParams < len(templateParams)):
templateParamsPrefix += text_type(templateParams[iTemplateParams])
iTemplateParams += 1
name.describe_signature(signode, 'markType', # type: ignore
name.describe_signature(dest, 'markType', # type: ignore
env, templateParamsPrefix + prefix, symbol)
prefix += text_type(name)
if mode == 'lastIsName':
if len(self.names) > 1:
signode += addnodes.desc_addname('::', '::')
dest += addnodes.desc_addname('::', '::')
signode += dest
if self.templates[-1]:
signode += nodes.Text("template ")
self.names[-1].describe_signature(signode, mode, env, '', symbol)

View File

@ -1035,9 +1035,11 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
# typing) we try to use the constructor signature as function
# signature without the first argument.
try:
args = Signature(self.object.__new__, bound_method=True).format_args()
sig = Signature(self.object.__new__, bound_method=True, has_retval=False)
args = sig.format_args()
except TypeError:
args = Signature(self.object.__init__, bound_method=True).format_args()
sig = Signature(self.object.__init__, bound_method=True, has_retval=False)
args = sig.format_args()
# escape backslashes for reST
args = args.replace('\\', '\\\\')
@ -1090,7 +1092,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
not(inspect.ismethod(initmeth) or inspect.isfunction(initmeth)):
return None
try:
return Signature(initmeth, bound_method=True).format_args()
return Signature(initmeth, bound_method=True, has_retval=False).format_args()
except TypeError:
# still not possible: happens e.g. for old-style classes
# with __init__ in C

View File

@ -298,8 +298,8 @@ class Signature(object):
its return annotation.
"""
def __init__(self, subject, bound_method=False):
# type: (Callable, bool) -> None
def __init__(self, subject, bound_method=False, has_retval=True):
# type: (Callable, bool, bool) -> None
# check subject is not a built-in class (ex. int, str)
if (isinstance(subject, type) and
is_builtin_class_method(subject, "__new__") and
@ -307,6 +307,7 @@ class Signature(object):
raise TypeError("can't compute signature for built-in type {}".format(subject))
self.subject = subject
self.has_retval = has_retval
self.partialmethod_with_noargs = False
if PY3:
@ -375,7 +376,10 @@ class Signature(object):
def return_annotation(self):
# type: () -> Any
if PY3 and self.signature:
return self.signature.return_annotation
if self.has_retval:
return self.signature.return_annotation
else:
return inspect.Parameter.empty
else:
return None

View File

@ -18,6 +18,7 @@ from collections import defaultdict
from os import path
from docutils import nodes, writers
from docutils.utils.roman import toRoman
from docutils.writers.latex2e import Babel
from six import itervalues, text_type
@ -1514,8 +1515,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('\\begin{enumerate}\n')
if 'start' in node:
nested = get_nested_level(node)
self.body.append('\\setcounter{enum%s}{%d}\n' % ('i' * nested, node['start'] - 1))
enum_depth = "enum%s" % toRoman(get_nested_level(node)).lower()
self.body.append('\\setcounter{%s}{%d}\n' % (enum_depth, node['start'] - 1))
if self.table:
self.table.has_problematic = True

View File

@ -9,6 +9,12 @@ nested-enumerated-list
10) Pyramid
11) Nile River
(x) Atbara
(y) Blue Nile
(#) Sobat
(#) Semliki
(#) Kagera
6. Markup
iii. reStructuredText

View File

@ -1239,4 +1239,5 @@ def test_latex_nested_enumerated_list(app, status, warning):
assert r'\setcounter{enumi}{4}' in result
assert r'\setcounter{enumii}{3}' in result
assert r'\setcounter{enumiii}{9}' in result
assert r'\setcounter{enumiv}{23}' in result
assert r'\setcounter{enumii}{2}' in result

View File

@ -280,6 +280,10 @@ def test_Signature_annotations():
sig = inspect.Signature(f11).format_args()
assert sig == '(x: CustomAnnotation, y: 123) -> None'
# has_retval=False
sig = inspect.Signature(f11, has_retval=False).format_args()
assert sig == '(x: CustomAnnotation, y: 123)'
def test_safe_getattr_with_default():
class Foo(object):