Skip to content

Commit

Permalink
Improve inheritance diagrams
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
QuLogic committed Dec 15, 2022
1 parent ab3d63d commit aa1ae8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions doc/_static/mpl.css
Expand Up @@ -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;
}
7 changes: 6 additions & 1 deletion doc/conf.py
Expand Up @@ -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
Expand Down

0 comments on commit aa1ae8d

Please sign in to comment.