Do not pass attr_docs as an argument into ModuleScanner.scan

This commit is contained in:
Matyas Novak 2022-03-14 23:29:51 +01:00
parent 033ebab15e
commit d955098ef9

View File

@ -193,8 +193,10 @@ class ModuleScanner:
name, exc, type='autosummary')
return False
def scan(self, imported_members: bool, attr_docs: Mapping[str,str] = {}) -> List[str]:
def scan(self, imported_members: bool) -> List[str]:
members = []
analyzer = ModuleAnalyzer.for_module(self.object.__name__)
attr_docs = analyzer.find_attr_docs()
for name in members_of(self.object, self.app.config):
try:
value = safe_getattr(self.object, name)
@ -306,6 +308,8 @@ def generate_autosummary_content(name: str, obj: Any, parent: Any,
"""Find module attributes with docstrings."""
attrs, public = [], []
try:
analyzer = ModuleAnalyzer.for_module(name)
attr_docs = analyzer.find_attr_docs()
for namespace, attr_name in attr_docs:
if namespace == '' and attr_name in members:
attrs.append(attr_name)
@ -334,10 +338,8 @@ def generate_autosummary_content(name: str, obj: Any, parent: Any,
ns.update(context)
if doc.objtype == 'module':
analyzer = ModuleAnalyzer.for_module(name)
attr_docs = analyzer.find_attr_docs()
scanner = ModuleScanner(app, obj)
ns['members'] = scanner.scan(imported_members, attr_docs)
ns['members'] = scanner.scan(imported_members)
ns['functions'], ns['all_functions'] = \
get_members(obj, {'function'}, imported=imported_members)
ns['classes'], ns['all_classes'] = \