From aa1ae8d87a4f35e4fc061f95cb9feab524553250 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 20 Jan 2022 03:12:17 -0500 Subject: [PATCH] Improve inheritance diagrams When Graphviz is given a page size (which Sphinx does by default), it will layout the whole graph, and then scale the _entire_ thing down to fit. This means that text and lines on large diagrams are inconsistent with ones that fit. Additionally, the default size is larger than the content width which means the browser will also scale the image down a bit. But the URL map is _not_ scaled down, so the links will appear in the wrong spot. To fix this, set the page size in Graphviz very large, and make the diagram scrollable with CSS. Plus a few minor tweaks to font and line sizes now that images are a consistent scale. --- doc/_static/mpl.css | 10 ++++++++++ doc/conf.py | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/_static/mpl.css b/doc/_static/mpl.css index 7cf24a748b0a..360aaac57604 100644 --- a/doc/_static/mpl.css +++ b/doc/_static/mpl.css @@ -99,3 +99,13 @@ table.property-table td { display: inline-block; margin: 0 0.5em; } + +/* Make inheritance images have a scroll bar if necessary. */ +div.graphviz { + border: 1px solid lightgrey; + max-height: 50em; + overflow: auto; +} +img.graphviz.inheritance { + max-width: none; +} diff --git a/doc/conf.py b/doc/conf.py index 80282c70a7bb..dd7ba1cebf9e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -619,7 +619,12 @@ def js_tag_with_cache_busting(js): numpydoc_show_class_members = False -inheritance_node_attrs = dict(fontsize=16) +# We want to prevent any size limit, as we'll add scroll bars with CSS. +inheritance_graph_attrs = dict(dpi=100, size='1000.0', splines='polyline') +# Also remove minimum node dimensions, and increase line size a bit. +inheritance_node_attrs = dict(height=0.02, margin=0.055, penwidth=1, + width=0.01) +inheritance_edge_attrs = dict(penwidth=1) graphviz_dot = shutil.which('dot') # Still use PNG until SVG linking is fixed