mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '1.7' into latex_deeply_nested_enumlist
This commit is contained in:
11
CHANGES
11
CHANGES
@@ -19,10 +19,15 @@ Bugs fixed
|
|||||||
* #4924: html search: Upper characters problem in any other languages
|
* #4924: html search: Upper characters problem in any other languages
|
||||||
* #4932: apidoc: some subpackage is ignored if sibling subpackage contains a
|
* #4932: apidoc: some subpackage is ignored if sibling subpackage contains a
|
||||||
module starting with underscore
|
module starting with underscore
|
||||||
* #4938, #4939: i18n doesn't handle node.title correctly tat used for contents,
|
* #4863, #4938, #4939: i18n doesn't handle node.title correctly tat used for
|
||||||
topic, admonition, table and section.
|
contents, topic, admonition, table and section.
|
||||||
* #4913: i18n: literal blocks in bullet list are not translated
|
* #4913: i18n: literal blocks in bullet list are not translated
|
||||||
* #4962: cpp domain: raises TypeError on duplicate declaration
|
* #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: deeply nested enumerated list which is beginning with non-1 causes
|
||||||
LaTeX engine crashed
|
LaTeX engine crashed
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class Epub3Builder(_epub_base.EpubBuilder):
|
|||||||
navstack[-1].children.append(navpoint)
|
navstack[-1].children.append(navpoint)
|
||||||
navstack.append(navpoint)
|
navstack.append(navpoint)
|
||||||
else:
|
else:
|
||||||
raise
|
raise RuntimeError('Should never reach here. It might be a bug.')
|
||||||
|
|
||||||
return navstack[0].children
|
return navstack[0].children
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
import re
|
import re
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes, utils
|
||||||
from docutils.parsers.rst import Directive, directives
|
from docutils.parsers.rst import Directive, directives
|
||||||
from six import iteritems, text_type
|
from six import iteritems, text_type
|
||||||
|
|
||||||
@@ -1965,26 +1965,34 @@ class ASTNestedName(ASTBase):
|
|||||||
prefix = '' # type: unicode
|
prefix = '' # type: unicode
|
||||||
first = True
|
first = True
|
||||||
names = self.names[:-1] if mode == 'lastIsName' else self.names
|
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)):
|
for i in range(len(names)):
|
||||||
name = names[i]
|
name = names[i]
|
||||||
template = self.templates[i]
|
template = self.templates[i]
|
||||||
if not first:
|
if not first:
|
||||||
signode += nodes.Text('::')
|
dest += nodes.Text('::')
|
||||||
prefix += '::'
|
prefix += '::'
|
||||||
if template:
|
if template:
|
||||||
signode += nodes.Text("template ")
|
dest += nodes.Text("template ")
|
||||||
first = False
|
first = False
|
||||||
if name != '':
|
if name != '':
|
||||||
if (name.templateArgs and # type: ignore
|
if (name.templateArgs and # type: ignore
|
||||||
iTemplateParams < len(templateParams)):
|
iTemplateParams < len(templateParams)):
|
||||||
templateParamsPrefix += text_type(templateParams[iTemplateParams])
|
templateParamsPrefix += text_type(templateParams[iTemplateParams])
|
||||||
iTemplateParams += 1
|
iTemplateParams += 1
|
||||||
name.describe_signature(signode, 'markType', # type: ignore
|
name.describe_signature(dest, 'markType', # type: ignore
|
||||||
env, templateParamsPrefix + prefix, symbol)
|
env, templateParamsPrefix + prefix, symbol)
|
||||||
prefix += text_type(name)
|
prefix += text_type(name)
|
||||||
if mode == 'lastIsName':
|
if mode == 'lastIsName':
|
||||||
if len(self.names) > 1:
|
if len(self.names) > 1:
|
||||||
signode += addnodes.desc_addname('::', '::')
|
dest += addnodes.desc_addname('::', '::')
|
||||||
|
signode += dest
|
||||||
if self.templates[-1]:
|
if self.templates[-1]:
|
||||||
signode += nodes.Text("template ")
|
signode += nodes.Text("template ")
|
||||||
self.names[-1].describe_signature(signode, mode, env, '', symbol)
|
self.names[-1].describe_signature(signode, mode, env, '', symbol)
|
||||||
@@ -5962,7 +5970,7 @@ class CPPExprRole(object):
|
|||||||
class Warner(object):
|
class Warner(object):
|
||||||
def warn(self, msg):
|
def warn(self, msg):
|
||||||
inliner.reporter.warning(msg, line=lineno)
|
inliner.reporter.warning(msg, line=lineno)
|
||||||
|
text = utils.unescape(text).replace('\n', ' ')
|
||||||
env = inliner.document.settings.env
|
env = inliner.document.settings.env
|
||||||
parser = DefinitionParser(text, Warner(), env.config)
|
parser = DefinitionParser(text, Warner(), env.config)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1035,9 +1035,11 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
|
|||||||
# typing) we try to use the constructor signature as function
|
# typing) we try to use the constructor signature as function
|
||||||
# signature without the first argument.
|
# signature without the first argument.
|
||||||
try:
|
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:
|
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
|
# escape backslashes for reST
|
||||||
args = args.replace('\\', '\\\\')
|
args = args.replace('\\', '\\\\')
|
||||||
@@ -1090,7 +1092,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
not(inspect.ismethod(initmeth) or inspect.isfunction(initmeth)):
|
not(inspect.ismethod(initmeth) or inspect.isfunction(initmeth)):
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return Signature(initmeth, bound_method=True).format_args()
|
return Signature(initmeth, bound_method=True, has_retval=False).format_args()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# still not possible: happens e.g. for old-style classes
|
# still not possible: happens e.g. for old-style classes
|
||||||
# with __init__ in C
|
# with __init__ in C
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{%- macro script() %}
|
{%- macro script() %}
|
||||||
<script type="text/javascript" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
|
<script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
|
||||||
{%- for scriptfile in script_files %}
|
{%- for scriptfile in script_files %}
|
||||||
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
|
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: '{{ url_root }}',
|
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||||
VERSION: '{{ release|e }}',
|
VERSION: '{{ release|e }}',
|
||||||
LANGUAGE: '{{ language }}',
|
LANGUAGE: '{{ language }}',
|
||||||
COLLAPSE_INDEX: false,
|
COLLAPSE_INDEX: false,
|
||||||
|
|||||||
@@ -298,8 +298,8 @@ class Signature(object):
|
|||||||
its return annotation.
|
its return annotation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, subject, bound_method=False):
|
def __init__(self, subject, bound_method=False, has_retval=True):
|
||||||
# type: (Callable, bool) -> None
|
# type: (Callable, bool, bool) -> None
|
||||||
# check subject is not a built-in class (ex. int, str)
|
# check subject is not a built-in class (ex. int, str)
|
||||||
if (isinstance(subject, type) and
|
if (isinstance(subject, type) and
|
||||||
is_builtin_class_method(subject, "__new__") 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))
|
raise TypeError("can't compute signature for built-in type {}".format(subject))
|
||||||
|
|
||||||
self.subject = subject
|
self.subject = subject
|
||||||
|
self.has_retval = has_retval
|
||||||
self.partialmethod_with_noargs = False
|
self.partialmethod_with_noargs = False
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
@@ -375,7 +376,10 @@ class Signature(object):
|
|||||||
def return_annotation(self):
|
def return_annotation(self):
|
||||||
# type: () -> Any
|
# type: () -> Any
|
||||||
if PY3 and self.signature:
|
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:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -280,6 +280,10 @@ def test_Signature_annotations():
|
|||||||
sig = inspect.Signature(f11).format_args()
|
sig = inspect.Signature(f11).format_args()
|
||||||
assert sig == '(x: CustomAnnotation, y: 123) -> None'
|
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():
|
def test_safe_getattr_with_default():
|
||||||
class Foo(object):
|
class Foo(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user