Merge branch '2.0' into 6708_mathbase

This commit is contained in:
Takeshi KOMIYA 2019-10-14 11:20:29 +09:00 committed by GitHub
commit 2da8638df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Features added
--------------
* #6707: C++, support bit-fields.
* #267: html: Eliminate prompt characters of doctest block from copyable text
Bugs fixed
----------
@ -30,6 +31,7 @@ Bugs fixed
* #6655: image URLs containing ``data:`` causes gettext builder crashed
* #6584: i18n: Error when compiling message catalogs on Hindi
* #6708: mathbase: Some deprecated functions have removed
* #6709: autodoc: mock object does not work as a class decorator
Testing
--------

View File

@ -60,7 +60,7 @@ class _MockObject:
return _make_subclass(key, self.__display_name__, self.__class__)()
def __call__(self, *args, **kw) -> Any:
if args and type(args[0]) in [FunctionType, MethodType]:
if args and type(args[0]) in [type, FunctionType, MethodType]:
# Appears to be a decorator, pass through unchanged
return args[0]
return self

View File

@ -672,6 +672,10 @@ div.code-block-caption + div > div.highlight > pre {
margin-top: 0;
}
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
user-select: none;
}
div.code-block-caption span.caption-number {
padding: 0.1em 0.3em;
font-style: italic;

View File

@ -269,6 +269,16 @@ class UnreferencedFootnotesDetector(SphinxTransform):
location=node)
class DoctestTransform(SphinxTransform):
"""Set "doctest" style to each doctest_block node"""
default_priority = 500
def apply(self, **kwargs):
# type: (Any) -> None
for node in self.document.traverse(nodes.doctest_block):
node['classes'].append('doctest')
class FigureAligner(SphinxTransform):
"""
Align figures to center by default.
@ -402,6 +412,7 @@ def setup(app: "Sphinx") -> Dict[str, Any]:
app.add_transform(MoveModuleTargets)
app.add_transform(HandleCodeBlocks)
app.add_transform(SortIds)
app.add_transform(DoctestTransform)
app.add_transform(FigureAligner)
app.add_transform(AutoNumbering)
app.add_transform(AutoIndexUpgrader)

View File

@ -96,3 +96,24 @@ def test_abc_MockObject():
assert isinstance(obj, Base)
assert isinstance(obj, _MockObject)
assert isinstance(obj.some_method(), Derived)
def test_mock_decorator():
mock = _MockObject()
@mock.function_deco
def func():
"""docstring"""
class Foo:
@mock.method_deco
def meth(self):
"""docstring"""
@mock.class_deco
class Bar:
"""docstring"""
assert func.__doc__ == "docstring"
assert Foo.meth.__doc__ == "docstring"
assert Bar.__doc__ == "docstring"