2009-03-04 16:52:56 -06:00
|
|
|
.. highlight:: rest
|
|
|
|
|
2009-03-04 17:17:14 -06:00
|
|
|
:mod:`sphinx.ext.graphviz` -- Add Graphviz graphs
|
|
|
|
=================================================
|
2009-03-04 16:52:56 -06:00
|
|
|
|
|
|
|
.. module:: sphinx.ext.graphviz
|
|
|
|
:synopsis: Support for Graphviz graphs.
|
|
|
|
|
|
|
|
.. versionadded:: 0.6
|
|
|
|
|
2018-01-20 16:04:57 -06:00
|
|
|
This extension allows you to embed `Graphviz <https://graphviz.org/>`_ graphs in
|
2009-03-04 16:52:56 -06:00
|
|
|
your documents.
|
|
|
|
|
|
|
|
It adds these directives:
|
|
|
|
|
2010-04-17 03:39:51 -05:00
|
|
|
.. rst:directive:: graphviz
|
2009-03-04 16:52:56 -06:00
|
|
|
|
|
|
|
Directive to embed graphviz code. The input code for ``dot`` is given as the
|
|
|
|
content. For example::
|
|
|
|
|
|
|
|
.. graphviz::
|
|
|
|
|
|
|
|
digraph foo {
|
|
|
|
"bar" -> "baz";
|
|
|
|
}
|
|
|
|
|
2010-01-02 14:38:27 -06:00
|
|
|
In HTML output, the code will be rendered to a PNG or SVG image (see
|
|
|
|
:confval:`graphviz_output_format`). In LaTeX output, the code will be
|
|
|
|
rendered to an embeddable PDF file.
|
2009-03-04 16:52:56 -06:00
|
|
|
|
2010-08-23 08:07:28 -05:00
|
|
|
You can also embed external dot files, by giving the file name as an
|
|
|
|
argument to :rst:dir:`graphviz` and no additional content::
|
|
|
|
|
|
|
|
.. graphviz:: external.dot
|
|
|
|
|
|
|
|
As for all file references in Sphinx, if the filename is absolute, it is
|
|
|
|
taken as relative to the source directory.
|
|
|
|
|
|
|
|
.. versionchanged:: 1.1
|
|
|
|
Added support for external files.
|
|
|
|
|
2019-06-02 04:18:55 -05:00
|
|
|
.. rubric:: options
|
|
|
|
|
|
|
|
.. rst:directive:option:: alt: alternate text
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
The alternate text of the graph. By default, the graph code is used to
|
|
|
|
the alternate text.
|
|
|
|
|
|
|
|
.. versionadded:: 1.0
|
|
|
|
|
|
|
|
.. rst:directive:option:: align: alignment of the graph
|
|
|
|
:type: left, center or right
|
|
|
|
|
|
|
|
The horizontal alignment of the graph.
|
|
|
|
|
|
|
|
.. versionadded:: 1.5
|
|
|
|
|
|
|
|
.. rst:directive:option:: caption: caption of the graph
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
The caption of the graph.
|
|
|
|
|
|
|
|
.. versionadded:: 1.1
|
|
|
|
|
2019-06-02 06:51:18 -05:00
|
|
|
.. rst:directive:option:: layout: layout type of the graph
|
2019-06-02 04:18:55 -05:00
|
|
|
:type: text
|
|
|
|
|
2019-06-02 06:51:18 -05:00
|
|
|
The layout of the graph (ex. ``dot``, ``neato`` and so on). A path to the
|
|
|
|
graphviz commands are also allowed. By default, :confval:`graphviz_dot`
|
|
|
|
is used.
|
2019-06-02 04:18:55 -05:00
|
|
|
|
|
|
|
.. versionadded:: 1.4
|
2019-06-02 06:51:18 -05:00
|
|
|
.. versionchanged:: 2.2
|
|
|
|
|
|
|
|
Renamed from ``graphviz_dot``
|
2019-06-02 04:18:55 -05:00
|
|
|
|
|
|
|
.. rst:directive:option:: name: label
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
The label of the graph.
|
|
|
|
|
|
|
|
.. versionadded:: 1.6
|
|
|
|
|
2019-12-26 22:56:15 -06:00
|
|
|
.. rst:directive:option:: class: class names
|
|
|
|
:type: a list of class names separeted by spaces
|
|
|
|
|
|
|
|
The class name of the graph.
|
|
|
|
|
|
|
|
.. versionadded:: 2.4
|
|
|
|
|
2009-03-04 16:52:56 -06:00
|
|
|
|
2010-04-17 03:39:51 -05:00
|
|
|
.. rst:directive:: graph
|
2009-03-04 16:52:56 -06:00
|
|
|
|
|
|
|
Directive for embedding a single undirected graph. The name is given as a
|
|
|
|
directive argument, the contents of the graph are the directive content.
|
|
|
|
This is a convenience directive to generate ``graph <name> { <content> }``.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
.. graph:: foo
|
|
|
|
|
|
|
|
"bar" -- "baz";
|
|
|
|
|
2015-07-25 10:04:06 -05:00
|
|
|
.. note:: The graph name is passed unchanged to Graphviz. If it contains
|
|
|
|
non-alphanumeric characters (e.g. a dash), you will have to double-quote
|
|
|
|
it.
|
|
|
|
|
2019-06-02 04:18:55 -05:00
|
|
|
.. rubric:: options
|
|
|
|
|
|
|
|
Same as :rst:dir:`graphviz`.
|
|
|
|
|
|
|
|
.. rst:directive:option:: alt: alternate text
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
.. versionadded:: 1.0
|
|
|
|
|
|
|
|
.. rst:directive:option:: align: alignment of the graph
|
|
|
|
:type: left, center or right
|
|
|
|
|
|
|
|
.. versionadded:: 1.5
|
|
|
|
|
|
|
|
.. rst:directive:option:: caption: caption of the graph
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
.. versionadded:: 1.1
|
|
|
|
|
2019-06-02 06:51:18 -05:00
|
|
|
.. rst:directive:option:: layout: layout type of the graph
|
2019-06-02 04:18:55 -05:00
|
|
|
:type: text
|
|
|
|
|
|
|
|
.. versionadded:: 1.4
|
2019-06-02 06:51:18 -05:00
|
|
|
.. versionchanged:: 2.2
|
|
|
|
|
|
|
|
Renamed from ``graphviz_dot``
|
2019-06-02 04:18:55 -05:00
|
|
|
|
|
|
|
.. rst:directive:option:: name: label
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
.. versionadded:: 1.6
|
|
|
|
|
2019-12-26 22:56:15 -06:00
|
|
|
.. rst:directive:option:: class: class names
|
|
|
|
:type: a list of class names separeted by spaces
|
|
|
|
|
|
|
|
The class name of the graph.
|
|
|
|
|
|
|
|
.. versionadded:: 2.4
|
|
|
|
|
2009-03-04 16:52:56 -06:00
|
|
|
|
2010-04-17 03:39:51 -05:00
|
|
|
.. rst:directive:: digraph
|
2009-03-04 16:52:56 -06:00
|
|
|
|
|
|
|
Directive for embedding a single directed graph. The name is given as a
|
|
|
|
directive argument, the contents of the graph are the directive content.
|
|
|
|
This is a convenience directive to generate ``digraph <name> { <content> }``.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
.. digraph:: foo
|
|
|
|
|
|
|
|
"bar" -> "baz" -> "quux";
|
|
|
|
|
2019-06-02 04:18:55 -05:00
|
|
|
.. rubric:: options
|
|
|
|
|
|
|
|
Same as :rst:dir:`graphviz`.
|
|
|
|
|
|
|
|
.. rst:directive:option:: alt: alternate text
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
.. versionadded:: 1.0
|
|
|
|
|
|
|
|
.. rst:directive:option:: align: alignment of the graph
|
|
|
|
:type: left, center or right
|
|
|
|
|
|
|
|
.. versionadded:: 1.5
|
|
|
|
|
|
|
|
.. rst:directive:option:: caption: caption of the graph
|
|
|
|
:type: text
|
|
|
|
|
|
|
|
.. versionadded:: 1.1
|
2009-03-04 16:52:56 -06:00
|
|
|
|
2019-06-02 06:51:18 -05:00
|
|
|
.. rst:directive:option:: layout: layout type of the graph
|
2019-06-02 04:18:55 -05:00
|
|
|
:type: text
|
2010-01-03 05:02:31 -06:00
|
|
|
|
2019-06-02 04:18:55 -05:00
|
|
|
.. versionadded:: 1.4
|
2019-06-02 06:51:18 -05:00
|
|
|
.. versionchanged:: 2.2
|
|
|
|
|
|
|
|
Renamed from ``graphviz_dot``
|
2016-01-18 09:53:10 -06:00
|
|
|
|
2019-06-02 04:18:55 -05:00
|
|
|
.. rst:directive:option:: name: label
|
|
|
|
:type: text
|
2016-01-18 08:56:05 -06:00
|
|
|
|
2019-06-02 04:18:55 -05:00
|
|
|
.. versionadded:: 1.6
|
2016-05-25 11:50:21 -05:00
|
|
|
|
2019-12-26 22:56:15 -06:00
|
|
|
.. rst:directive:option:: class: class names
|
|
|
|
:type: a list of class names separeted by spaces
|
|
|
|
|
|
|
|
The class name of the graph.
|
|
|
|
|
|
|
|
.. versionadded:: 2.4
|
|
|
|
|
2016-11-12 08:05:59 -06:00
|
|
|
|
2019-02-26 10:09:43 -06:00
|
|
|
There are also these config values:
|
2009-03-04 16:52:56 -06:00
|
|
|
|
|
|
|
.. confval:: graphviz_dot
|
|
|
|
|
|
|
|
The command name with which to invoke ``dot``. The default is ``'dot'``; you
|
|
|
|
may need to set this to a full path if ``dot`` is not in the executable
|
|
|
|
search path.
|
|
|
|
|
|
|
|
Since this setting is not portable from system to system, it is normally not
|
|
|
|
useful to set it in ``conf.py``; rather, giving it on the
|
2016-01-11 22:36:12 -06:00
|
|
|
:program:`sphinx-build` command line via the :option:`-D <sphinx-build -D>`
|
|
|
|
option should be preferable, like this::
|
2009-03-04 16:52:56 -06:00
|
|
|
|
|
|
|
sphinx-build -b html -D graphviz_dot=C:\graphviz\bin\dot.exe . _build/html
|
|
|
|
|
|
|
|
.. confval:: graphviz_dot_args
|
|
|
|
|
|
|
|
Additional command-line arguments to give to dot, as a list. The default is
|
|
|
|
an empty list. This is the right place to set global graph, node or edge
|
|
|
|
attributes via dot's ``-G``, ``-N`` and ``-E`` options.
|
2010-01-02 14:38:27 -06:00
|
|
|
|
|
|
|
.. confval:: graphviz_output_format
|
|
|
|
|
|
|
|
The output format for Graphviz when building HTML files. This must be either
|
2015-12-16 21:33:17 -06:00
|
|
|
``'png'`` or ``'svg'``; the default is ``'png'``. 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="http://sphinx-doc.org", target="_top"];
|
|
|
|
b [label="other"];
|
|
|
|
a -> b;
|
|
|
|
}
|
2010-01-02 14:38:27 -06:00
|
|
|
|
|
|
|
.. versionadded:: 1.0
|
|
|
|
Previously, output always was PNG.
|