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

Add option include-subclasses to inheritance-diagram #8191

Closed
doerwalter opened this issue Sep 10, 2020 · 3 comments · Fixed by #8159
Closed

Add option include-subclasses to inheritance-diagram #8191

doerwalter opened this issue Sep 10, 2020 · 3 comments · Fixed by #8159
Labels
extensions:graphviz The `sphinx.ext.graphviz` or `sphinx.ext.inheritance_diagram` extensions type:enhancement enhance or introduce a new feature
Milestone

Comments

@doerwalter
Copy link
Contributor

doerwalter commented Sep 10, 2020

Is your feature request related to a problem? Please describe.

When I have a module that contains many classes and some of them are related through inheritance and some are not, then I have the following problem: I'd like to create an inheritance diagram for one of the classes in this module and all of its subclasses. However when I specify the module in inheritance-diagram the diagram will contain the unrelated classes too. top-classes doesn't work either. The only working approach is to list each of the subclasses individually.

Describe the solution you'd like
I'd like an option to specify that any subclass of classes in the list of classes for the inheritance-diagram should be included in the diagram too.

I.e. if I have a module m with the following classes:

class A: ...
class B: ...
class C(B): ...
class D(B): ...

Then the following Sphinx code:

.. inheritance-diagram:: m.B
	:include-subclasses:

will create an inheritance diagram including the classes B, C and D.

Additional context

I have this problem in the following project:

http://python.livinglogic.de/XIST_Howto.html

The class Node has 25 subclasses, so to show Node and all of its subclasses the Sphinx code looks like this:

.. inheritance-diagram:: ll.xist.xsc.Node ll.xist.xsc.Frag ll.xist.xsc.Element ll.xist.xsc.Attrs ll.xist.xsc.Entity ll.xist.xsc.Attr ll.xist.xsc.BoolAttr ll.xist.xsc.ColorAttr ll.xist.xsc.NumberAttr ll.xist.xsc.FloatAttr ll.xist.xsc.IntAttr ll.xist.xsc.IDAttr ll.xist.xsc.StyleAttr ll.xist.xsc.TextAttr ll.xist.xsc.URLAttr ll.xist.xsc.CharacterData ll.xist.xsc.Text ll.xist.xsc.CharRef ll.xist.xsc.amp ll.xist.xsc.apos ll.xist.xsc.gt ll.xist.xsc.lt ll.xist.xsc.quot ll.xist.xsc.Comment ll.xist.xsc.DocType ll.xist.xsc.ProcInst
	:parts: 1

With this its likely that I might miss a class when typing this list, or might forget to add it when a new subclass gets added. With the include-subclasses option the code would look like this:

.. inheritance-diagram:: ll.xist.xsc.Node
	:include-subclasses:
	:parts: 1

which IMHO is much simpler and saver.

Pull request

A pull request that implements this feature can be found here:

#8159

@doerwalter doerwalter added the type:enhancement enhance or introduce a new feature label Sep 10, 2020
@doerwalter
Copy link
Contributor Author

Is there something missing that I still need to provide? What can I do to move this pull request along?

@polfeliu
Copy link

polfeliu commented Nov 2, 2021

This feature would be great, I would like to use it for a project of mine. Is there anything we can do to get this moving? Seems to be stuck for no reason.

@aantn
Copy link

aantn commented Dec 19, 2021

I'm also interested in this.

@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
@AA-Turner AA-Turner added the extensions:graphviz The `sphinx.ext.graphviz` or `sphinx.ext.inheritance_diagram` extensions label Jan 15, 2024
@AA-Turner AA-Turner modified the milestones: some future version, 8.2.0 Feb 2, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions:graphviz The `sphinx.ext.graphviz` or `sphinx.ext.inheritance_diagram` extensions type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants