AshDiagram.Renderer behaviour (AshDiagram v0.1.2)

View Source

Behaviour for rendering AshDiagram diagrams.

Summary

Types

Single rendering option for customizing diagram output.

List of rendering options. See option/0 for available options.

Callbacks

Render the diagram to the specified format.

Determine if the current environment supports this renderer.

Functions

Render the diagram to the specified format, using the configured renderer.

Types

color()

@type color() :: String.t()

dimension()

@type dimension() :: pos_integer()

format()

@type format() :: :svg | :png | :pdf

option()

@type option() ::
  {:theme, theme()}
  | {:format, format()}
  | {:width, dimension()}
  | {:height, dimension()}
  | {:background_color, color()}
  | {:config_file, Path.t()}
  | {:svg_id, String.t()}
  | {:scale, float()}
  | {:puppeteer_config_file, Path.t()}
  | {:icon_packs, [String.t()]}

Single rendering option for customizing diagram output.

Available Options

  • {:theme, theme()} - Visual theme (:default, :forest, :dark, :neutral)
  • {:format, format()} - Output format (:svg, :png, :pdf)
  • {:width, dimension()} - Output width in pixels
  • {:height, dimension()} - Output height in pixels
  • {:background_color, color()} - Background color (e.g., "white", "#ffffff")
  • {:config_file, Path.t()} - Path to Mermaid configuration file
  • {:svg_id, String.t()} - Custom SVG element ID
  • {:scale, float()} - Scale factor for output (e.g., 1.0, 2.0)
  • {:puppeteer_config_file, Path.t()} - Path to Puppeteer configuration
  • {:icon_packs, [String.t()]} - List of icon pack names

Examples

# Set dark theme with PNG output
[{:theme, :dark}, {:format, :png}]

# High resolution SVG with custom size
[{:format, :svg}, {:width, 1920}, {:height, 1080}, {:scale, 2.0}]

# PDF with custom background color
[{:format, :pdf}, {:background_color, "#f8f9fa"}]

options()

@type options() :: [option()]

List of rendering options. See option/0 for available options.

theme()

@type theme() :: :default | :forest | :dark | :neutral

Callbacks

render(diagram, options)

@callback render(diagram :: iodata(), options :: options()) :: iodata()

Render the diagram to the specified format.

supported?()

@callback supported?() :: boolean()

Determine if the current environment supports this renderer.

Functions

render(diagram, options \\ [])

@spec render(diagram :: iodata(), options :: options()) :: iodata()

Render the diagram to the specified format, using the configured renderer.