Graphviz

Hinweis

Graphviz-Tools müssen installiert und verfügbar sein.

Konfiguration

extensions = [
    'sphinx.ext.graphviz',
]
graphviz_output_format = 'svg'

Beispiel 1

Quellcode

.. graphviz::
    :name: sphinx.ext.graphviz
    :caption: Sphinx and GraphViz Data Flow [#fn1]_
    :alt: How Sphinx and GraphViz Render the Final Document
    :align: center

     digraph "sphinx-ext-graphviz" {
         size="6,4";
         rankdir="LR";
         graph [fontname="Verdana", fontsize="12"];
         node [fontname="Verdana", fontsize="12"];
         edge [fontname="Sans", fontsize="9"];

         sphinx [label="Sphinx", shape="component",
                   href="https://www.sphinx-doc.org/",
                   target="_blank"];
         dot [label="GraphViz", shape="component",
              href="https://www.graphviz.org/",
              target="_blank"];
         docs [label="Docs (.rst)", shape="folder",
               fillcolor=green, style=filled];
         svg_file [label="SVG Image", shape="note", fontcolor=white,
                 fillcolor="#3333ff", style=filled];
         html_files [label="HTML Files", shape="folder",
              fillcolor=yellow, style=filled];

         docs -> sphinx [label=" parse "];
         sphinx -> dot [label=" call ", style=dashed, arrowhead=none];
         dot -> svg_file [label=" draw "];
         sphinx -> html_files [label=" render "];
         svg_file -> html_files [style=dashed];
     }

Ausgabe

How Sphinx and GraphViz Render the Final Document

Sphinx and GraphViz Data Flow 1

Beispiel 2

Ein Hassediagramm

Quellcode

In externer Datei:

graph  {
  a c d e h
  d -- a;
  e -- c;
  e -- d;
  h -- e;
}

Ausgabe

graph { a c d e h d -- a; e -- c; e -- d; h -- e; }

Fußnoten

1

https://jhermann.github.io/blog/python/documentation/2020/03/25/sphinx_ext_graphviz.html