sphinx.ext.graphviz – Ajouter des graphiques Graphviz

Ajouté dans la version 0.6.

Cette extension vous permet d’intégrer Graphviz graphiques dans vos documents.

Important

Graphviz must be present on your machine; please refer to the official instructions if it is not the case.

Il ajoute ces directives :

.. graphviz::

Directive pour intégrer le code de graphviz. Le code d’entrée pour « point » est donné comme contenu. Par exemple: :

.. graphviz::

   digraph foo {
      "bar" -> "baz";
   }

En sortie HTML, le code sera rendu en image PNG ou SVG (voir graphviz_output_format). En sortie LaTeX, le code sera rendu dans un fichier PDF intégrable.

Vous pouvez également intégrer des fichiers de points externes, en donnant le nom du fichier en argument à graphviz et sans contenu supplémentaire:

.. graphviz:: external.dot

Comme pour toutes les références de fichiers dans Sphinx, si le nom de fichier est absolu, il est considéré comme relatif au répertoire source.

Modifié dans la version 1.1: Ajout de la prise en charge des fichiers externes.

options

:alt: alternate text (text)

The alternate text of the graph. By default, the graph code is used to the alternate text.

Ajouté dans la version 1.0.

:align: alignment of the graph (left, center or right)

The horizontal alignment of the graph.

Ajouté dans la version 1.5.

:caption: caption of the graph (text)

The caption of the graph.

Ajouté dans la version 1.1.

:layout: layout type of the graph (text)

The layout of the graph (e.g. dot, neato and so on). A path to the graphviz commands are also allowed. By default, graphviz_dot is used.

Ajouté dans la version 1.4.

Modifié dans la version 2.2: Renamed from graphviz_dot

:name: label (text)

The label of the graph.

Ajouté dans la version 1.6.

:class: class names (a list of class names separated by spaces)

The class name of the graph.

Ajouté dans la version 2.4.

.. graph::

Directive pour l’intégration d’un seul graphique non dirigé. Le nom est donné en argument directive, le contenu du graphique est le contenu de la directive. Ceci est une directive de commodité pour générer graph <name> { <content> }.

Pas exemple:

.. graph:: foo

   "bar" -- "baz";

Note

Le nom du graphique est transmis inchangé à Graphviz ; s’il contient des caractères non alphanumériques (p. ex. un tiret), vous devez le citer deux fois.

options

Same as graphviz.

:alt: alternate text (text)

Ajouté dans la version 1.0.

:align: alignment of the graph (left, center or right)

Ajouté dans la version 1.5.

:caption: caption of the graph (text)

Ajouté dans la version 1.1.

:layout: layout type of the graph (text)

Ajouté dans la version 1.4.

Modifié dans la version 2.2: Renamed from graphviz_dot

:name: label (text)

Ajouté dans la version 1.6.

:class: class names (a list of class names separated by spaces)

The class name of the graph.

Ajouté dans la version 2.4.

.. digraph::

Directive pour l’intégration d’un seul graphique orienté. Le nom est donné en argument directive, le contenu du graphique est le contenu de la directive. Ceci est une directive de commodité pour générer digraph <name> { <content> }.

Pas exemple:

.. digraph:: foo

   "bar" -> "baz" -> "quux";

options

Same as graphviz.

:alt: alternate text (text)

Ajouté dans la version 1.0.

:align: alignment of the graph (left, center or right)

Ajouté dans la version 1.5.

:caption: caption of the graph (text)

Ajouté dans la version 1.1.

:layout: layout type of the graph (text)

Ajouté dans la version 1.4.

Modifié dans la version 2.2: Renamed from graphviz_dot

:name: label (text)

Ajouté dans la version 1.6.

:class: class names (a list of class names separated by spaces)

The class name of the graph.

Ajouté dans la version 2.4.

There are also these config values:

graphviz_dot
Type:
str
Défaut:
'dot'

The command name with which to invoke dot. You may need to set this to a full path if dot is not in the executable search path.

Comme ce paramètre n’est pas portable d’un système à l’autre, il n’est normalement pas utile de le définir dans conf.py ; plutôt, le donner sur la ligne de commande program:sphinx-build via l’option -D” devrait être préférable, comme ceci :

sphinx-build -M html -D graphviz_dot=C:\graphviz\bin\dot.exe . _build
graphviz_dot_args
Type:
Sequence[str]
Défaut:
()

Additional command-line arguments to give to dot, as a list. This is the right place to set global graph, node or edge attributes via dot’s -G, -N and -E options.

graphviz_output_format
Type:
'png' | 'svg'
Défaut:
'png'

The output format for Graphviz when building HTML files. This must be either 'png' or 'svg'. If 'svg' is used, in order to make the URL links work properly, an appropriate target attribute must be set, such as "_top" and "_blank". For example, the link in the following graph should work in the svg output:

.. graphviz::

     digraph example {
         a [label="sphinx", href="https://www.sphinx-doc.org/", target="_top"];
         b [label="other"];
         a -> b;
     }

Ajouté dans la version 1.0: Auparavant, la sortie était toujours en PNG.