Configuration#

Optional parameters#

When calling the .. uml directive, you can pass the following options:

  • :classes: enables the UML class diagram display;

  • :packages: enables the package diagram display;

  • :caption: S, where S is an arbitrary RST line of text, defines the caption of the resulting image(s).

See the examples section.

conf.py#

sphinx-uml specific options#

To configure this extension in a Sphinx documentation, update the docs/conf.py:

Example:

# sphinx-uml switches
uml_colorized = True  # colour the graphs
uml_all_ancestors = True  # give more Sphinx context
uml_all_associated = True

The table below list the supported parameters:

Sphinx option pyreverse2 option Default value
uml_filter_mode --filter_mode FILTER "PUB_ONLY"
uml_class --class CLASSES []
uml_show_ancestors --show_ancestors LEVEL None
uml_all_ancestors --all_ancestors False
uml_show_associated --show_associated None
uml_all_associated --all_associated False
uml_show_builtin --show_builtin False
uml_module_names --module_names MODULES False
uml_only_classnames --only_classnames False
uml_ignore --ignore IGNORE ("CVS",)
uml_colorized --colorized False

See also:

  • example/docs/doc.conf as an example:

  • pyreverse --help for more details about each option.

Environment#

By default, the directive provided by this package is named uml. Optionally, you can rename it by defining its name through the SPHINX_UML_DIRECTIVE environment variable.

sphinx-uml inherited options#

sphinx-uml uses relies on some display options provided by:

  • graphviz.ext.graphviz

  • graphviz.ext.inheritance_diagram

Example:

# Options related to sphinx.ext.graphviz.
# Thus, it also impacts sphinx.ext.inheritance_diagram and sphinx_uml.
graphviz_output_format = "svg"

# Options related to sphinx.ext.inheritance_diagram
bgcolor = "transparent"
fgcolor = "black"  # Note that night mode will change this to white
inheritance_graph_attrs = {
    "rankdir": "BT",
    "fontcolor": fgcolor,
    "bgcolor": bgcolor,
}
inheritance_node_attrs = inheritance_edge_attrs = {
    "color": fgcolor,
    "fontcolor": fgcolor,
}