mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3900: autosummary could not find methods
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -45,6 +45,7 @@ Bugs fixed
|
|||||||
setting.
|
setting.
|
||||||
* #3840: make checking ``epub_uid`` strict
|
* #3840: make checking ``epub_uid`` strict
|
||||||
* #3851, #3706: Fix about box drawing characters for PDF output
|
* #3851, #3706: Fix about box drawing characters for PDF output
|
||||||
|
* #3900: autosummary could not find methods
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|||||||
@@ -195,7 +195,10 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
|||||||
continue
|
continue
|
||||||
documenter = get_documenter(value, obj)
|
documenter = get_documenter(value, obj)
|
||||||
if documenter.objtype == typ:
|
if documenter.objtype == typ:
|
||||||
if imported or getattr(value, '__module__', None) == obj.__name__:
|
if typ == 'method':
|
||||||
|
items.append(name)
|
||||||
|
elif imported or getattr(value, '__module__', None) == obj.__name__:
|
||||||
|
# skip imported members if expected
|
||||||
items.append(name)
|
items.append(name)
|
||||||
public = [x for x in items
|
public = [x for x in items
|
||||||
if x in include_public or not x.startswith('_')]
|
if x in include_public or not x.startswith('_')]
|
||||||
|
|||||||
9
tests/roots/test-ext-autosummary/autodoc_dummy_module.py
Normal file
9
tests/roots/test-ext-autosummary/autodoc_dummy_module.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from os import *
|
||||||
|
|
||||||
|
|
||||||
|
class Foo:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def bar(self):
|
||||||
|
pass
|
||||||
9
tests/roots/test-ext-autosummary/conf.py
Normal file
9
tests/roots/test-ext-autosummary/conf.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import sys, os
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
|
extensions = ['sphinx.ext.autosummary']
|
||||||
|
autosummary_generate = True
|
||||||
|
|
||||||
|
# The suffix of source filenames.
|
||||||
|
source_suffix = '.rst'
|
||||||
6
tests/roots/test-ext-autosummary/contents.rst
Normal file
6
tests/roots/test-ext-autosummary/contents.rst
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:toctree: generated
|
||||||
|
|
||||||
|
autodoc_dummy_module
|
||||||
|
autodoc_dummy_module.Foo
|
||||||
@@ -126,3 +126,22 @@ def test_escaping(app, status, warning):
|
|||||||
title = etree_parse(docpage).find('section/title')
|
title = etree_parse(docpage).find('section/title')
|
||||||
|
|
||||||
assert str_content(title) == 'underscore_module_'
|
assert str_content(title) == 'underscore_module_'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx('dummy', testroot='ext-autosummary')
|
||||||
|
def test_autosummary_generate(app, status, warning):
|
||||||
|
app.builder.build_all()
|
||||||
|
|
||||||
|
module = (app.srcdir / 'generated' / 'autodoc_dummy_module.rst').text()
|
||||||
|
assert (' .. autosummary::\n'
|
||||||
|
' \n'
|
||||||
|
' Foo\n'
|
||||||
|
' \n' in module)
|
||||||
|
|
||||||
|
Foo = (app.srcdir / 'generated' / 'autodoc_dummy_module.Foo.rst').text()
|
||||||
|
assert '.. automethod:: __init__' in Foo
|
||||||
|
assert (' .. autosummary::\n'
|
||||||
|
' \n'
|
||||||
|
' ~Foo.__init__\n'
|
||||||
|
' ~Foo.bar\n'
|
||||||
|
' \n' in Foo)
|
||||||
|
|||||||
Reference in New Issue
Block a user