Merge branch 'stable'

This commit is contained in:
Takeshi KOMIYA
2017-11-12 01:53:28 +09:00
7 changed files with 34 additions and 1 deletions

View File

@@ -107,6 +107,8 @@ Bugs fixed
----------
* #4206: latex: reST label between paragraphs loses paragraph break
* #4231: html: Apply fixFirefoxAnchorBug only under Firefox
* #2298: automodule fails to document a class attribute
Testing
--------

View File

@@ -1267,6 +1267,17 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
return
ModuleLevelDocumenter.document_members(self, all_members)
def generate(self, more_content=None, real_modname=None,
check_module=False, all_members=False):
# Do not pass real_modname and use the name from the __module__
# attribute of the class.
# If a class gets imported into the module real_modname
# the analyzer won't find the source of the class, if
# it looks in real_modname.
return super(ClassDocumenter, self).generate(more_content=more_content,
check_module=check_module,
all_members=all_members)
class ExceptionDocumenter(ClassDocumenter):
"""

View File

@@ -206,7 +206,7 @@ var Documentation = {
* see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
*/
fixFirefoxAnchorBug : function() {
if (document.location.hash)
if (document.location.hash && $.browser.mozilla)
window.setTimeout(function() {
document.location.href += '';
}, 10);

View File

@@ -28,6 +28,11 @@ viewcode
:language: python
:pyobject: func1
.. autoclass:: spam.mod3.Class3
:members:
.. automodule:: spam.mod3
:members:
.. toctree::

View File

@@ -18,3 +18,10 @@ class Class1(object):
"""
this is Class1
"""
class Class3(object):
"""
this is Class3
"""
class_attr = 42
"""this is the class attribute class_attr"""

View File

@@ -0,0 +1,2 @@
from spam.mod1 import Class3
__all__ = ('Class3',)

View File

@@ -32,6 +32,12 @@ def test_viewcode(app, status, warning):
assert result.count('href="_modules/spam/mod2.html#Class2"') == 2
assert result.count('@decorator') == 1
# test that the class attribute is correctly documented
assert result.count('this is Class3') == 2
assert 'this is the class attribute class_attr' in result
# the next assert fails, until the autodoc bug gets fixed
assert result.count('this is the class attribute class_attr') == 2
@pytest.mark.sphinx(testroot='ext-viewcode', tags=['test_linkcode'])
def test_linkcode(app, status, warning):