var DagrePlugin = dagrePlugin{}
var ELKPlugin = elkPlugin{}
func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error
func HydratePluginOpts(ctx context.Context, ms *xmain.State, plugin Plugin) error
func Serve(p Plugin) xmain.RunFunc
Serve returns a xmain.RunFunc that will invoke the plugin p as necessary to service the calling d2 CLI.
See implementation of d2plugin-dagre in the ./cmd directory.
Also see execPlugin in exec.go for the d2 binary plugin protocol.
type Plugin interface { // Info returns the current info information of the plugin. Info(context.Context) (*PluginInfo, error) Flags(context.Context) ([]PluginSpecificFlag, error) HydrateOpts([]byte) error // Layout runs the plugin's autolayout algorithm on the input graph // and returns a new graph with the computed placements. Layout(context.Context, *d2graph.Graph) error // PostProcess makes changes to the default render PostProcess(context.Context, []byte) ([]byte, error) }
func FindPlugin(ctx context.Context, ps []Plugin, name string) (Plugin, error)
FindPlugin finds the plugin with the given name.
func ListPlugins(ctx context.Context) ([]Plugin, error)
type PluginFeature string
When this is true, containers can have dimensions set
const CONTAINER_DIMENSIONS PluginFeature = "container_dimensions"
When this is true, containers can have connections to descendants
const DESCENDANT_EDGES PluginFeature = "descendant_edges"
When this is true, objects can set their `near` key to another object When this is false, objects can only set `near` to constants
const NEAR_OBJECT PluginFeature = "near_object"
When this is true, the plugin also implements RoutingPlugin interface to route edges
const ROUTES_EDGES PluginFeature = "routes_edges"
When this is true, objects can specify their `top` and `left` keywords
const TOP_LEFT PluginFeature = "top_left"
PluginInfo is the current info information of a plugin. note: The two fields Type and Path are not set by the plugin itself but only in ListPlugins.
type PluginInfo struct { Name string `json:"name"` ShortHelp string `json:"shortHelp"` LongHelp string `json:"longHelp"` // Set to bundled when returning from the plugin. // execPlugin will set to binary when used. // bundled | binary Type string `json:"type"` // If Type == binary then this contains the absolute path to the binary. Path string `json:"path"` Features []PluginFeature `json:"features"` }
func ListPluginInfos(ctx context.Context, ps []Plugin) ([]*PluginInfo, error)
type PluginSpecificFlag struct { Name string Type string Default interface{} Usage string // Must match the tag in the opt Tag string }
func ListPluginFlags(ctx context.Context, ps []Plugin) ([]PluginSpecificFlag, error)
func (f *PluginSpecificFlag) AddToOpts(opts *xmain.Opts)
type RoutingPlugin interface { // RouteEdges runs the plugin's edge routing algorithm for the given edges in the input graph RouteEdges(context.Context, *d2graph.Graph, []*d2graph.Edge) error }