sphinx_uml.uml_generate_directive module#

class sphinx_uml.uml_generate_directive.UMLGenerateDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#

Bases: SphinxDirective

UML directive to generate a pyreverse diagram

final_argument_whitespace = True#

May the final argument contain whitespace?

has_content = False#

May the directive have content?

html_root_dir() Path[source]#

Crafts the HTML prefix to move from the current HTML to the HTML root directory.

Returns:

The corresponding relative Path instance.

Example

Assume that:

  • the documentation is built in: "~/git/sphinx-uml/docs";

  • the current document is; "~/git/sphinx-uml/docs/users/examples.rst";

Then, the returned value is "../". As the HTML hierarchy follows the RST hierarchy, we use this prefix to setup our SphinxHtmlProxy.

option_spec: ClassVar[dict[str, Callable[[str], Any]]] = {'caption': <function unchanged>, 'classes': <function flag>, 'packages': <function flag>}#

Mapping of option names to validator functions.

optional_arguments = 0#

Number of optional arguments after the required arguments.

required_arguments = 1#

Number of required directive arguments.

run()[source]#

To test this extension, as a developer:

To test this pyreverse2, called by this extension:

class sphinx_uml.uml_generate_directive.UmlNode(rawsource='', *children, **attributes)[source]#

Bases: graphviz

Defines a UML docutils node. We populate its attribute so that we can rely on the default graphviz node.

classmethod from_dot(dotcode: str) UmlNode[source]#

Builds a UmlNode instance from a Graphviz dot string.

Parameters:

dotcode (str) – A Graphviz dot string. Example: digraph G {0 -> 1}

Returns:

The resulting UmlNode instance.

classmethod from_pyreverse(diagram: ClassDiagram | PackageDiagram, config: Namespace) UmlNode[source]#

Builds a UmlNode from a diagram definition obtained from pyreverse.

Parameters:
  • diagram (ClassDiagram | PackageDiagram) – The diagram that must be exported.

  • config (argparse.Namespace) – The configuration obtained from the Sphinx configuration file.

Returns:

The resulting UmlNode instance.

classmethod to_dot(diagram: ClassDiagram | PackageDiagram, config: Namespace) str[source]#

Exports a diagram definition obtained from pyreverse to a Graphviz dot string.

Parameters:
  • diagram (ClassDiagram | PackageDiagram) – The diagram that must be exported.

  • config (argparse.Namespace) – The configuration obtained from the Sphinx configuration file.

Returns:

The resulting UmlNode instance.

sphinx_uml.uml_generate_directive.guess_svg_basename(options: dict, code: str) str[source]#

Infers the svg filename of an UML diagram See /usr/lib/python3/dist-packages/sphinx/ext/graphviz.py.

Parameters:
  • options (dict) – The options passed to the graphviz.ext.render_dot() function.

  • code (str) – A graphviz string, passed to the graphviz.ext.render_dot() function.

Returns:

The corresponding SVG basename