Skip to content

Commit

Permalink
Add example demonstrating inheritance diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
j9ac9k committed May 27, 2024
1 parent aa49c21 commit d8f77d7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"sphinx.ext.autosummary",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.graphviz",
"sphinxext.rediraffe",
"sphinx_design",
"sphinx_copybutton",
Expand Down Expand Up @@ -90,6 +91,17 @@
"jupyter": ("Jupyter", "https://jupyter.org"),
}


# -- sphinx_ext_graphviz options ---------------------------------------------

graphviz_output_format = 'svg'
inheritance_graph_attrs = dict(
rankdir="LR",
fontsize=14,
ratio='compress',
# bgcolor='transparent',
)

# -- sphinx_togglebutton options ---------------------------------------------
togglebutton_hint = str(_("Click to expand"))
togglebutton_hint_hide = str(_("Click to collapse"))
Expand Down
28 changes: 28 additions & 0 deletions docs/examples/kitchen-sink/graphviz.rst
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d8f77d7

Please sign in to comment.