diff --git a/autodocsumm/__init__.py b/autodocsumm/__init__.py index 5808308..79cdf29 100755 --- a/autodocsumm/__init__.py +++ b/autodocsumm/__init__.py @@ -39,6 +39,7 @@ __status__ = "Production" +import inspect from itertools import chain from sphinx.util import logging @@ -223,6 +224,19 @@ def get_grouped_documenters(self, all_members=False): members = [(membername, member) for (membername, member) in members if membername not in self.options.exclude_members] + # If the object is a class, verify that we are documenting the original + # definition of the class and not an alias of the class. This is + # checked by ensuring that the objects full (importable) name is + # equal to the documented full name. This may differ, e.g. if the + # object is just a class attribute that references another class. + # Sphinx will already at an "alias of" + link to original definition + if inspect.isclass(self.object): + obj_modname = getattr(self.object, '__module__', '') + obj_qname = getattr(self.object, '__qualname__', '') + obj_fullname = obj_modname + '.' + obj_qname + if obj_modname and obj_qname and obj_fullname != self.fullname: + members = [] + # document non-skipped members memberdocumenters = [] registry = self.env.app.registry.documenters