diff --git a/autodocsumm/__init__.py b/autodocsumm/__init__.py index 5808308..a191eb0 100755 --- a/autodocsumm/__init__.py +++ b/autodocsumm/__init__.py @@ -220,8 +220,16 @@ def get_grouped_documenters(self, all_members=False): # remove members given by exclude-members if self.options.exclude_members: - members = [(membername, member) for (membername, member) in members - if membername not in self.options.exclude_members] + try: + members = [ + member for member in members + if member.__name__ not in self.options.exclude_members + ] + except AttributeError: # Sphinx<3.4.0 + members = [ + (membername, member) for (membername, member) in members + if membername not in self.options.exclude_members + ] # document non-skipped members memberdocumenters = [] diff --git a/tests/test-root/index.rst b/tests/test-root/index.rst index 4f6b787..528fb4e 100644 --- a/tests/test-root/index.rst +++ b/tests/test-root/index.rst @@ -5,6 +5,7 @@ Example documentation test_module test_module_summary_only + test_module_exclude_members test_class test_class_order test_class_summary_only diff --git a/tests/test-root/test_module_exclude_members.rst b/tests/test-root/test_module_exclude_members.rst new file mode 100644 index 0000000..f2d2c13 --- /dev/null +++ b/tests/test-root/test_module_exclude_members.rst @@ -0,0 +1,5 @@ +Docs of dummy test without some members +======================================= + +.. automodule:: dummy + :autosummary-exclude-members: InheritedTestClass, diff --git a/tests/test_autodocsumm.py b/tests/test_autodocsumm.py index 1fdcb59..1c8edc0 100644 --- a/tests/test_autodocsumm.py +++ b/tests/test_autodocsumm.py @@ -484,6 +484,17 @@ def test_automodulesumm_nosignatures(self, app): assert '()' not in html + def test_automodulesumm_exclude_members(self, app): + """Test building the autosummary of a module with some members + excluded from the autosummary.""" + app.build() + + html = get_html(app, 'test_module_exclude_members.html') + + assert in_autosummary("TestClass", html) + assert not in_autosummary("InheritedTestClass", html) + + def test_empty(self, app): app.build()