Skip to content

Commit 1b1fe1a

Browse files
committed
Add example demonstrating inheritance diagram
1 parent aa49c21 commit 1b1fe1a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

docs/conf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"sphinx.ext.autosummary",
3232
"sphinx.ext.todo",
3333
"sphinx.ext.viewcode",
34+
"sphinx.ext.graphviz",
3435
"sphinxext.rediraffe",
3536
"sphinx_design",
3637
"sphinx_copybutton",
@@ -90,6 +91,16 @@
9091
"jupyter": ("Jupyter", "https://jupyter.org"),
9192
}
9293

94+
95+
# -- sphinx_ext_graphviz options ---------------------------------------------
96+
97+
graphviz_output_format = "svg"
98+
inheritance_graph_attrs = dict(
99+
rankdir="LR",
100+
fontsize=14,
101+
ratio="compress",
102+
)
103+
93104
# -- sphinx_togglebutton options ---------------------------------------------
94105
togglebutton_hint = str(_("Click to expand"))
95106
togglebutton_hint_hide = str(_("Click to collapse"))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
========
2+
Graphviz
3+
========
4+
5+
Inheritance Diagram
6+
-------------------
7+
8+
Using `sphinx.ext.inheritance_diagram`, inheritance diagrams can be generated
9+
through `sphinx.ext.graphviz`. If the output of the inheritance diagrams are
10+
in `svg` format, they can be made to conform to light or dark mode.
11+
12+
To have the inheritance-diagram render to `svg`, inside `conf.py`, you need
13+
the following option.
14+
15+
.. code-block:: python
16+
17+
# conf.py
18+
...
19+
graphviz_output_format = 'svg'
20+
...
21+
22+
Below is an example of the inheritance diagram for ``matplotlib.figure.Figure``
23+
24+
.. inheritance-diagram:: matplotlib.figure.Figure
25+
26+
See the sphinx inheritance-diagram `documentation`_ for more information.
27+
28+
.. _documentation: https://www.sphinx-doc.org/en/master/usage/extensions/inheritance.html

0 commit comments

Comments
 (0)