mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
autosummary includes instance attributes
This commit is contained in:
parent
af6e63ab70
commit
6f8d9390df
@ -662,8 +662,9 @@ def import_ivar_by_name(name: str, prefixes: List[str] = [None]) -> Tuple[str, A
|
||||
name, attr = name.rsplit(".", 1)
|
||||
real_name, obj, parent, modname = import_by_name(name, prefixes)
|
||||
qualname = real_name.replace(modname + ".", "")
|
||||
analyzer = ModuleAnalyzer.for_module(modname)
|
||||
if (qualname, attr) in analyzer.find_attr_docs():
|
||||
analyzer = ModuleAnalyzer.for_module(getattr(obj, '__module__', modname))
|
||||
analyzer.analyze()
|
||||
if (qualname, attr) in analyzer.attr_docs or (qualname, attr) in analyzer.annotations:
|
||||
return real_name + "." + attr, INSTANCEATTR, obj, modname
|
||||
except (ImportError, ValueError, PycodeError):
|
||||
pass
|
||||
|
@ -239,15 +239,21 @@ def generate_autosummary_content(name: str, obj: Any, parent: Any,
|
||||
name, exc, type='autosummary')
|
||||
return False
|
||||
|
||||
def attr_getter(obj, name, *defargs):
|
||||
return sphinx.ext.autodoc.autodoc_attrgetter(app, obj, name, *defargs)
|
||||
|
||||
def get_all_members(obj):
|
||||
all_members = sphinx.ext.autodoc.get_class_members(obj, [qualname], attr_getter)
|
||||
return all_members
|
||||
|
||||
def get_members(obj: Any, types: Set[str], include_public: List[str] = [],
|
||||
imported: bool = True) -> Tuple[List[str], List[str]]:
|
||||
items: List[str] = []
|
||||
public: List[str] = []
|
||||
for name in dir(obj):
|
||||
try:
|
||||
value = safe_getattr(obj, name)
|
||||
except AttributeError:
|
||||
continue
|
||||
|
||||
all_members = get_all_members(obj)
|
||||
for name, member in all_members.items():
|
||||
value = member.object
|
||||
documenter = get_documenter(app, value, obj)
|
||||
if documenter.objtype in types:
|
||||
# skip imported members if expected
|
||||
|
Loading…
Reference in New Issue
Block a user