From 1b1fe1addf48a45e2bc4a71da35912004a1a2f45 Mon Sep 17 00:00:00 2001 From: Ognyan Moore Date: Mon, 27 May 2024 17:59:26 -0400 Subject: [PATCH] Add example demonstrating inheritance diagram --- docs/conf.py | 11 ++++++++++ docs/examples/kitchen-sink/graphviz.rst | 28 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docs/examples/kitchen-sink/graphviz.rst diff --git a/docs/conf.py b/docs/conf.py index 75c3a43a2..9be5b550f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,6 +31,7 @@ "sphinx.ext.autosummary", "sphinx.ext.todo", "sphinx.ext.viewcode", + "sphinx.ext.graphviz", "sphinxext.rediraffe", "sphinx_design", "sphinx_copybutton", @@ -90,6 +91,16 @@ "jupyter": ("Jupyter", "https://jupyter.org"), } + +# -- sphinx_ext_graphviz options --------------------------------------------- + +graphviz_output_format = "svg" +inheritance_graph_attrs = dict( + rankdir="LR", + fontsize=14, + ratio="compress", +) + # -- sphinx_togglebutton options --------------------------------------------- togglebutton_hint = str(_("Click to expand")) togglebutton_hint_hide = str(_("Click to collapse")) diff --git a/docs/examples/kitchen-sink/graphviz.rst b/docs/examples/kitchen-sink/graphviz.rst new file mode 100644 index 000000000..a003b70ff --- /dev/null +++ b/docs/examples/kitchen-sink/graphviz.rst @@ -0,0 +1,28 @@ +======== +Graphviz +======== + +Inheritance Diagram +------------------- + +Using `sphinx.ext.inheritance_diagram`, inheritance diagrams can be generated +through `sphinx.ext.graphviz`. If the output of the inheritance diagrams are +in `svg` format, they can be made to conform to light or dark mode. + +To have the inheritance-diagram render to `svg`, inside `conf.py`, you need +the following option. + +.. code-block:: python + + # conf.py + ... + graphviz_output_format = 'svg' + ... + +Below is an example of the inheritance diagram for ``matplotlib.figure.Figure`` + +.. inheritance-diagram:: matplotlib.figure.Figure + +See the sphinx inheritance-diagram `documentation`_ for more information. + +.. _documentation: https://www.sphinx-doc.org/en/master/usage/extensions/inheritance.html