Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Allow for use of graphviz as the "engine" for
needflow
(#1235)
This commit allows for the use of [`graphviz`](https://graphviz.org) as the underlying engine for `needflow` diagrams, in addition to the default [`plantuml`](https://plantuml.com). The intention being to simplify and improve performance of graph builds, since plantuml has issues with JVM initialisation times and reliance on a third-party sphinx extension. It introduces a new configuration option; `needs_flow_engine`, which can be set to either `plantuml` or `graphviz`, and defaults to `plantuml`, and a new directive option; `engine`, which can be set to either `plantuml` or `graphviz`, and defaults to `plantuml`. Thus, the `graphivz` engine can be activated on a per-diagram basis, or globally. The `graphviz` engine supports all the existing `needflow` options, although one key complication is the translation of existing "style related" configurations, which are hard-coded to plantuml syntax: - fields in `needs_extra_links`: `style`, `style_part`, `style_start`, `style_end` - `needs_flow_configs` - `needs_diagram_template` The `needs_extra_links` fields are translated to graphviz syntax, where possible, and warnings emitted for those that could not be. Two issues that probably cannot be resolved (it is unclear exactly how plantuml achieves them): 1. Link styles with a direction, such as `-up->` 2. Applying correct shapes for needs that contain children/parts; in graphviz nodes cannot contain other nodes, and instead we must use "subgraph clusters" for such nodes, which do not allow a `shape` attribute A separate `needs_graphviz_styles` configuration is introduced, which is similar to `needs_flow_configs`, except allowing graphviz attributes to be set (and used by the `needflow` directive's `config` option). `needs_diagram_template` is not used; currently the graphviz engine hard-codes the format of node labels, but this could potentially be added in the future. Additionally, an `alt` option is added to the `needflow` directive, and supported by both engines. Note, currently the rendering with the `graphviz` engine is restricted to HTML output only, this could fairly easily be extended to latex/man/text/texinfo, which `sphinx.ext.graphviz` already supports, the main reason it is not already, is that we override the visitor node currently, to make some improvements.
- Loading branch information