Skip to content

Commit

Permalink
don't document class attributes that are an alias to another object
Browse files Browse the repository at this point in the history
  • Loading branch information
theOehrly committed Aug 14, 2024
1 parent 354e67b commit 73baf9e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autodocsumm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

__status__ = "Production"

import inspect
from itertools import chain

from sphinx.util import logging
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 73baf9e

Please sign in to comment.