From 73baf9e6f24ea50d95c445228e569c2f9aef9b9f Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Wed, 14 Aug 2024 23:58:42 +0200 Subject: [PATCH] don't document class attributes that are an alias to another object --- autodocsumm/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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