sphinx
sphinx copied to clipboard
More precise selection of what is and what isn't included in an inheritance diagram
Is your feature request related to a problem? Please describe.
Currently there is no way to explicitly exclude a base from an inheritance diagram. A great example is that I have 7 classes in one file that are all abstract base classes for dozens more declared elsewhere. They all inherit from abc.ABC, and therefor abc.ABC will show up on my diagram whether I like it or not. (I think I could technically mark them all as top-classes and maybe get by? very tedious!)
Describe the solution you'd like
Explicitly excluding classes from the diagram should be possible. It seems that many uses of top-classes that I see in the documentation and on StackOverflow are just work-arounds to do just this. Users make a diagram, and then have a desire to remove one or more classes from it, and then are shepherded into using the top-classes option in odd ways to accomplish their goals.
Describe alternatives you've considered
I think this is the most clean solution, but it's possible there may be some other way to accomplish this. I view this as a parallel to the exclude-members in the autodoc extension, so the concept isn't new.
Additional context
One other minor note: top-classes doesn't allow you to use relative names (which you can use in the arguments if you are inside a .. module block), which is slightly annoying. I don't think it would be interface breaking to allow that, and I think it should be allowed for the suggested exclude-classes option.
Examples
https://www.sphinx-doc.org/en/master/usage/extensions/inheritance.html#examples https://github.com/sphinx-doc/sphinx/issues/7660
Looks like #7660 was an attempt to fix this and more, but I think the scope of this feature should be kept small and concise.