Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inherited-members should support more than one class #8417

Closed
drootang opened this issue Nov 13, 2020 · 2 comments
Closed

inherited-members should support more than one class #8417

drootang opened this issue Nov 13, 2020 · 2 comments
Labels
extensions:autodoc type:enhancement enhance or introduce a new feature
Milestone

Comments

@drootang
Copy link

Is your feature request related to a problem? Please describe.
I have two situations:

  • A class inherits from multiple other classes. I want to document members from some of the base classes but ignore some of the base classes
  • A module contains several class definitions that inherit from different classes that should all be ignored (e.g., classes that inherit from list or set or tuple). I want to ignore members from list, set, and tuple while documenting all other inherited members in classes in the module.

Describe the solution you'd like
The :inherited-members: option to automodule should accept a list of classes. If any of these classes are encountered as base classes when instantiating autoclass documentation, they should be ignored.

Describe alternatives you've considered
The alternative is to not use automodule, but instead manually enumerate several autoclass blocks for a module. This only addresses the second bullet in the problem description and not the first. It is also tedious for modules containing many class definitions.

@drootang drootang added the type:enhancement enhance or introduce a new feature label Nov 13, 2020
@tk0miya tk0miya added this to the 3.5.0 milestone Dec 31, 2020
@tk0miya
Copy link
Member

tk0miya commented Dec 31, 2020

+1: Acceptable change.

@tk0miya
Copy link
Member

tk0miya commented Dec 31, 2020

A class inherits from multiple other classes. I want to document members from some of the base classes but ignore some of the base classes

For example, there is a class that inherits multiple base classes:

class MyClass(Parent1, Parent2, Parent3, ...):
    pass

and

.. autoclass:: example.MyClass
   :inherited-members: Parent2

How should the new :inherited-members: work? Do you mean that the member of Parent2 are ignored and the Parent1's and Parent3's are documented? And how about the methods of the super classes of Parent1?

Note: The current behavior is ignoring Parent2, Parent3, and the super classes of them (including Parent1's also). In python words, the classes after Parent2 in MRO list are all ignored.

@tk0miya tk0miya modified the milestones: 3.5.0, 4.0.0 Feb 4, 2021
@tk0miya tk0miya modified the milestones: 4.0.0, 4.1.0 Mar 27, 2021
@tk0miya tk0miya modified the milestones: 4.1.0, 4.2.0 Jul 10, 2021
@tk0miya tk0miya modified the milestones: 4.2.0, 4.3.0 Sep 12, 2021
@tk0miya tk0miya modified the milestones: 4.3.0, 5.0.0 Nov 9, 2021
tk0miya added a commit to tk0miya/sphinx that referenced this issue Apr 2, 2022
…multiple classes

It allows to suppress inherited members of several classes on the module at
once by specifying the option to `automodule` directive
tk0miya added a commit to tk0miya/sphinx that referenced this issue Apr 2, 2022
…multiple classes

It allows to suppress inherited members of several classes on the module at
once by specifying the option to `automodule` directive
@tk0miya tk0miya closed this as completed in 21e3a96 Apr 3, 2022
tk0miya added a commit that referenced this issue Apr 3, 2022
…ist_of_classes

Close #8417: autodoc: :inherited-members: option now takes multiple classes
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions:autodoc type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

2 participants