| 1 |
Using Dot Graphs |
| 2 |
================ |
| 3 |
|
| 4 |
.. _graphviz: https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html#module-sphinx.ext.graphviz |
| 5 |
.. _dot: https://www.doxygen.nl/manual/commands.html#cmddot |
| 6 |
.. _dotfile: https://www.doxygen.nl/manual/commands.html#cmddotfile |
| 7 |
|
| 8 |
Sphinx graphviz prerequisites |
| 9 |
----------------------------- |
| 10 |
|
| 11 |
To use Sphinx's graphviz_ directive at all, the project documentation's ``conf.py`` file must have |
| 12 |
``sphinx.ext.graphviz`` added to the list of ``extensions``. |
| 13 |
|
| 14 |
.. code-block:: python |
| 15 |
|
| 16 |
extensions = ["breathe", "sphinx.ext.graphviz"] |
| 17 |
|
| 18 |
.. seealso:: |
| 19 |
To obtain the dot executable from the Graphviz library, see |
| 20 |
`the library's downloads section <https://graphviz.org/download/>`_. |
| 21 |
|
| 22 |
.. note:: |
| 23 |
Typically, the dot executable's path should be added to your system's ``PATH`` environment |
| 24 |
variable. This is required for Sphinx, although the configuration option, |
| 25 |
`graphviz_dot <https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html#confval-graphviz_dot>`_, |
| 26 |
can compensate for abnormal dot executable installations. |
| 27 |
|
| 28 |
``\dot`` and ``\dotfile`` commands |
| 29 |
---------------------------------- |
| 30 |
|
| 31 |
By default, breathe will translate any dot_ and dotfile_ commands into |
| 32 |
Sphinx graphviz_ directives. However, there are some caveats: |
| 33 |
|
| 34 |
1. The only graphviz_ option supported is the ``caption`` option. Graph captions are optionally |
| 35 |
specified using the dot_ or dotfile_ command syntax. All other graphviz_ directive options |
| 36 |
fallback to their default behavior. |
| 37 |
|
| 38 |
- any size hints from Doxygen's dot_ or dotfile_ commands are ignored. |
| 39 |
2. Using Doxygen's ``@ref`` command within any dot syntax is functionally ignored and treated as |
| 40 |
literal text. |
| 41 |
|
| 42 |
Generated graphs from Doxygen |
| 43 |
----------------------------- |
| 44 |
|
| 45 |
If Doxygen is configured to use the dot executable to generate certain graphs, then some of these |
| 46 |
graphs can be translated into Sphinx graphviz directives. Because this feature depends on having |
| 47 |
the dot executable installed to generate graphs in Sphinx, the option ``allow-dot-graphs`` must be |
| 48 |
specified for the following directives: |
| 49 |
|
| 50 |
- :ref:`doxygenclass` |
| 51 |
- :ref:`doxygenstruct` |
| 52 |
- :ref:`doxygenfile` |
| 53 |
- :ref:`doxygenindex` |
| 54 |
- :ref:`autodoxygenfile` |
| 55 |
- :ref:`autodoxygenindex` |
| 56 |
|
| 57 |
.. attention:: |
| 58 |
Only the following graphs generated by Doxygen can be found in its XML output: |
| 59 |
|
| 60 |
.. csv-table:: |
| 61 |
:header: graph relevance, configuration option |
| 62 |
|
| 63 |
files included within, `INCLUDE_GRAPH <https://www.doxygen.nl/manual/config.html#cfg_include_graph>`_ |
| 64 |
files included by, `INCLUDED_BY_GRAPH <https://www.doxygen.nl/manual/config.html#cfg_included_by_graph>`_ |
| 65 |
inheritance, `CLASS_GRAPH <https://www.doxygen.nl/manual/config.html#cfg_class_graph>`_ |
| 66 |
collaboration, `COLLABORATION_GRAPH <https://www.doxygen.nl/manual/config.html#cfg_collaboration_graph>`_ |
| 67 |
|
| 68 |
Unfortunately, the ``call`` and ``caller`` graphs are not provided by Doxygen's XML output. |
| 69 |
|
| 70 |
Examples of graphs generated by Doxygen are shown in this documentation's |
| 71 |
`Diagrams section of the doxygen test suite <doxygen.html#diagrams>`_ |
| 72 |
|
| 73 |
Example Graphs |
| 74 |
-------------- |
| 75 |
|
| 76 |
Graphs can be placed anywhere. For this example they are placed in a doxygen page. |
| 77 |
|
| 78 |
.. code-block:: rst |
| 79 |
|
| 80 |
.. doxygenpage:: dotgraphs |
| 81 |
:project: dot_graphs |
| 82 |
|
| 83 |
This will render as: |
| 84 |
|
| 85 |
.. doxygenpage:: dotgraphs |
| 86 |
:project: dot_graphs |