3.1.21. waf_tools.drawio

Integration of the draw.io diagram editor into the Waf build system.

This waf tool configures the drawio-desktop application (https://github.com/jgraph/drawio-desktop/releases) so that .drawio diagram files can be exported to SVG format as part of the Waf build process.

The tool registers a file extension handler for .drawio files. When a task generator includes .drawio files, a drawioToSvg task is automatically created that invokes the draw.io CLI to produce SVG output.

Note

The .drawio source files must not be empty. The drawio-desktop CLI cannot export empty files and will fail with Error: Export failed: <path>.

3.1.21.1. Usage

  1. The tool is loaded in waf_tools.sphinx_build.configure() and configured by find_drawio():

    # in sphinx_build.py
    def configure(ctx):
        ctx.find_drawio()
    
  2. In a build script, declare a task generator with .drawio source files:

    def build(bld):
        bld(
            source=bld.path.ant_glob("**/*.drawio"),
        )
    

3.1.21.2. Dependencies

  • drawio-desktop (draw.io on Windows, drawio on Linux)

Functions

drawio_hook(self, node)

Create a drawioToSvg task for a .drawio source node.

find_drawio(ctx)

Find the drawio-desktop executable and set default CLI options.

Classes

drawioToSvg(*k, **kw)

Task that converts a .drawio diagram file to SVG format.