Documentation
¶
Overview ¶
Package d2plugin enables the d2 CLI to run functions bundled with the d2 binary or via external plugin binaries.
Binary plugins are stored in $PATH with the prefix d2plugin-*. i.e the binary for dagre might be d2plugin-dagre. See ListPlugins() below.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DagrePlugin = dagrePlugin{}
var ELKPlugin = elkPlugin{}
Functions ¶
func FeatureSupportCheck ¶ added in v0.2.1
func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error
func HydratePluginOpts ¶ added in v0.1.4
Types ¶
type Plugin ¶
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 ¶
FindPlugin finds the plugin with the given name.
- It first searches the bundled plugins in the global plugins slice.
- If not found, it then searches each directory in $PATH for a binary with the name d2plugin-<name>.
- If such a binary is found, it builds an execPlugin in exec.go to get a plugin implementation around the binary and returns it.
type PluginFeature ¶ added in v0.2.1
type PluginFeature string
const CONTAINER_DIMENSIONS PluginFeature = "container_dimensions"
When this is true, containers can have dimensions set
const DESCENDANT_EDGES PluginFeature = "descendant_edges"
When this is true, containers can have connections to descendants
const NEAR_OBJECT PluginFeature = "near_object"
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 ROUTES_EDGES PluginFeature = "routes_edges"
When this is true, the plugin also implements RoutingPlugin interface to route edges
const TOP_LEFT PluginFeature = "top_left"
When this is true, objects can specify their `top` and `left` keywords
type PluginInfo ¶
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"` }
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.
func ListPluginInfos ¶ added in v0.1.5
func ListPluginInfos(ctx context.Context, ps []Plugin) ([]*PluginInfo, error)
type PluginSpecificFlag ¶ added in v0.1.4
type PluginSpecificFlag struct { Name string Type string Default interface{} Usage string // Must match the tag in the opt Tag string }
func ListPluginFlags ¶ added in v0.1.4
func ListPluginFlags(ctx context.Context, ps []Plugin) ([]PluginSpecificFlag, error)
func (*PluginSpecificFlag) AddToOpts ¶ added in v0.1.4
func (f *PluginSpecificFlag) AddToOpts(opts *xmain.Opts)