Skip to content

Commit 75c685d

Browse files
QuLogictacaswell
authored andcommitted
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.
1 parent 8a7a53a commit 75c685d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

doc/_static/mpl.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,13 @@ table.property-table td {
9999
display: inline-block;
100100
margin: 0 0.5em;
101101
}
102+
103+
/* Make inheritance images have a scroll bar if necessary. */
104+
div.graphviz {
105+
border: 1px solid lightgrey;
106+
max-height: 50em;
107+
overflow: auto;
108+
}
109+
img.graphviz.inheritance {
110+
max-width: none;
111+
}

doc/conf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,14 @@ def js_tag_with_cache_busting(js):
619619

620620
numpydoc_show_class_members = False
621621

622-
inheritance_node_attrs = dict(fontsize=16)
622+
html4_writer = True
623+
624+
# We want to prevent any size limit, as we'll add scroll bars with CSS.
625+
inheritance_graph_attrs = dict(dpi=100, size='1000.0', splines='polyline')
626+
# Also remove minimum node dimensions, and increase line size a bit.
627+
inheritance_node_attrs = dict(height=0.02, margin=0.055, penwidth=1,
628+
width=0.01)
629+
inheritance_edge_attrs = dict(penwidth=1)
623630

624631
graphviz_dot = shutil.which('dot')
625632
# Still use PNG until SVG linking is fixed

0 commit comments

Comments
 (0)