Add interactive class hierarchy visualization to docs#643
Add interactive class hierarchy visualization to docs#643johnjasa wants to merge 10 commits intoNatLabRockies:developfrom
Conversation
|
I think if the colors were refined a bit more so there were some broader classifications, the visualization would work a lot better. If there are overlappy categories, could we use different shapes or hatching to indicate this difference rather than a slightly different color. As it stands, it's hard to glean any relationships because many colors are very close. I can dig into the code itself if you'd like and come up with some recommendations, but this is my only real criticism |
|
Hey John! I love this figure and I think it's an awesome way to represent H2I! Jumping on the color feedback that Rob gave, could we separate the colors for the {control, core, and electricity} and {metal and storage} groups? I think I can make out the different oranges, but the blues are especially hard. |
|
I love this, thanks @johnjasa! Most of my thoughts while looking at it were about inconsistencies in our organization that we need to fix. I do have a couple of comments on the image itself though.
|
|
As @jaredthomas68 stated, the static images would make it easier to see the smaller, disconnected subgraphs. The relationships could also be broken up by headings and maybe introductory sentence as well (if needed). I think with the width issue being handled, I could go either way on the static images. |




Add interactive class hierarchy visualization to docs
This PR adds an autogenerated and interactive class hierarchy diagram to the developer guide documentation.
The visualization scans all Python files in the
h2integratepackage, extracts class definitions and inheritance relationships (excluding test and config classes), and produces a zoomable, pannable HTML graph embedded in the docs.Classes are color-coded by category (converters, storage, resource, finance, control, transporters, etc.) and spatially clustered by category so related models group together visually. Node sizes reflect the number of child classes, making base classes visually prominent.
The script uses
astto parse the codebase,networkxto build the inheritance graph andpyvisto render the layout.Running
python docs/generate_class_hierarchy.pyregenerates the figure, and it is now called automatically inbuild_book.sh.Periodically we should update the html output. I've added this to the PR template for new models.
I don't think it's worth adding a test for this viz at this time; it'd be a bit of effort to figure out how to confirm the correct production and appearance of the doc.
I used Claude Opus 4.6 for this PR, mainly in the layout and formatting of the viz code.
Section 1: Type of Contribution
Section 2: General PR Checklist
docs/files are up-to-date, or added when necessaryCHANGELOG.md"A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
XYZshould be replaced with the actual number.Section 3: Related Issues
None.
Section 4: Impacted Areas of the Software
Section 4.1: New Files
docs/generate_class_hierarchy.pyh2integrate/for all non-test, non-config classes, builds an inheritance graph withnetworkx, and renders an interactive HTML visualization usingpyviswith category-based color coding and spatial clustering.docs/developer_guide/class_hierarchy.htmlSection 4.2: Modified Files
docs/developer_guide/class_structure.mddocs/build_book.shpython generate_class_hierarchy.pybefore the Jupyter Book build so the diagram is regenerated on every doc build.Section 5: Additional Supporting Information
pyvispackage is a new dependency required only for doc generation (pip install pyvis). It is not needed at runtime.*Configdataclasses and test classes, showing only performance, cost, and other model classes.ExplicitComponentfrom OpenMDAO are excluded.