mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7036 from tk0miya/7023_partial_listed_as_module_members
Fix #7023: autodoc: partial functions are listed as module members
This commit is contained in:
commit
c4ed75752b
2
CHANGES
2
CHANGES
@ -53,6 +53,8 @@ Bugs fixed
|
||||
* #6999: napoleon: fails to parse tilde in :exc: role
|
||||
* #7019: gettext: Absolute path used in message catalogs
|
||||
* #7023: autodoc: nested partial functions are not listed
|
||||
* #7023: autodoc: partial functions imported from other modules are listed as
|
||||
module members without :impoprted-members: option
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -344,10 +344,9 @@ class Documenter:
|
||||
if self.options.imported_members:
|
||||
return True
|
||||
|
||||
modname = self.get_attr(self.object, '__module__', None)
|
||||
if inspect.ispartial(self.object) and modname == '_functools': # for pypy
|
||||
return True
|
||||
elif modname and modname != self.modname:
|
||||
subject = inspect.unpartial(self.object)
|
||||
modname = self.get_attr(subject, '__module__', None)
|
||||
if modname and modname != self.modname:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
1
tests/roots/test-ext-autodoc/target/imported_members.py
Normal file
1
tests/roots/test-ext-autodoc/target/imported_members.py
Normal file
@ -0,0 +1 @@
|
||||
from .partialfunction import func2, func3
|
@ -1267,6 +1267,17 @@ def test_partialfunction():
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('setup_test')
|
||||
def test_imported_partialfunction_should_not_shown_without_imported_members():
|
||||
options = {"members": None}
|
||||
actual = do_autodoc(app, 'module', 'target.imported_members', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:module:: target.imported_members',
|
||||
''
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('setup_test')
|
||||
def test_bound_method():
|
||||
options = {"members": None}
|
||||
|
Loading…
Reference in New Issue
Block a user