mdl

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2020 License: MIT Imports: 11 Imported by: 3

Documentation

Overview

Package mdl generates all the information required to render diagrams from a model design into static web pages. The information includes the Mermaid source code for the diagram as well as information for each node that can be used to further style the diagram, add links etc.

The package can be used in two different ways:

  • As a library: the function Render produces data structures for each view in a design that include the source code for a Mermaid diagram and additional information useful for visualizing the diagrams (e.g. links, style classes and element properties).
  • As a Goa plugin: by adding 'import _ "goa.design/model/plugin"' to the Goa design. Running 'goa gen' produces Mermaid diagrams in the 'gen/diagrams' directory and a JSON representation of a structurizr workspace in 'gen/structurizr'.

The tool located in goa.design/model/cmd/mdl makes use of the library to generate the information or pages directly given the import path to the Go package containing the model design.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MermaidFiles

func MermaidFiles(d *expr.Design) (files []*codegen.File)

MermaidFiles returns codegen files that render Mermaid diagrams describing the views described in the given design. There is one file generated per view in the design.

TBD: dynamic views, animations

Types

type Node

type Node struct {
	// ID is the node ID.
	ID string
	// URL is the URL specified in the element design.
	URL string
	// Properties are the properties specified in the element design.
	Properties map[string]string
	// ElementViewKey is the key of the first view in the design that is
	// scoped to the node element if any. This is useful to create links
	// to child element diagrams for example.
	ElementViewKey string
}

Node contains information about a single diagram node (element).

type RenderedView

type RenderedView struct {
	// Key is the key of the view.
	Key string
	// Title of view
	Title string
	// Version of design
	Version string
	// Description of view if any
	Description string
	// Mermaid contains the Mermaid source for the diagram.
	Mermaid string
	// Legend contains the Mermaid source for the legend.
	Legend string
	// Nodes contains additional information for each node rendered in the
	// diagram and is indexed by node ID (which corresponds to the ID of the
	// underlying element).
	Nodes map[string]*Node
}

RenderedView contains the information needed to create a static web page containing a view diagram.

func Render

func Render(d *expr.Design) []*RenderedView

Render renders the views of the given design.

TBD: dynamic views, animations

func RunDSL

func RunDSL() ([]*RenderedView, error)

RunDSL runs the DSL defined in a global variable and returns the corresponding rendered views.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL