Documentation
¶
Overview ¶
Package view renders a SysML view: it turns the elements a view exposes into a rendering artifact, in the form the view's `render` member states.
SysML v2 §10.2 states which rendering a view uses and leaves how a tool carries it out to the tool, so everything this package produces — the text form and the Mermaid form alike — is tool-defined output rather than a notation the specification defines. What is read from the model is not: ordinary renderings use semantics.Model.ExposedElements, while a matrix opts into semantics.Model.ExposedMembers; connections come from the model's own connector information, and states and actions from the lowered graphs in internal/ir/lower, never from the source text of a declaration.
Index ¶
- Constants
- Variables
- func CheckPicture(location string, data []byte) error
- func CompartmentsNames() string
- func DrawingStyleNames() string
- func ElementNames() string
- func FormNames(forms []Form) string
- func InlineMermaidImages(source, base string) string
- func LinesNames() string
- func MermaidFits(source string) bool
- func MermaidLimits(sources ...string) (textSize, edges int)
- func MermaidSize(source string) (textSize, edges int)
- func OverlayNames() string
- func PaletteNames() string
- func ParseDepth(value string) (int, error)
- func ParseLinkTemplate(template string) error
- func PortsNames() string
- func PseudoViewSpecs() []string
- func RemotePictureLocation(location string) bool
- func TableColumns() []string
- func UnplacedNames() string
- type ActionLocator
- type Canvas
- type Compartment
- type Compartments
- type Data
- type DepthError
- type Direction
- type DrawingStyle
- type Drawn
- type Edge
- type EdgeData
- type EdgeKind
- type Element
- type Fill
- type Form
- type Geometry
- type Kind
- func (k Kind) GraphShaped() bool
- func (k Kind) MachineForm() Form
- func (k Kind) Supported() bool
- func (k Kind) SupportedForms() []Form
- func (k Kind) SupportsDirection() bool
- func (k Kind) SupportsForm(form Form) bool
- func (k Kind) SupportsOverlay(o Overlay) bool
- func (k Kind) SupportsPalette() bool
- func (k Kind) SupportsPorts() bool
- func (k Kind) Tabular() bool
- type Lane
- type LaneTransition
- type Lines
- type Links
- type Locator
- type Mark
- type Node
- type NodeData
- type Note
- type Options
- type Origin
- type Overlay
- type Palette
- type Picture
- type PilotStyle
- type Point
- type Port
- type PortDirection
- type Ports
- type RelatedGroup
- type RelatedKind
- type Renderer
- func (r *Renderer) DefaultKind(exposed []*symbols.Symbol) Kind
- func (r *Renderer) DrawnIn(view *symbols.Symbol) (*Drawn, error)
- func (r *Renderer) DrawsAnywhere(sym *symbols.Symbol) (node, edge bool)
- func (r *Renderer) DrawsSpecializationAnywhere(sym, general *symbols.Symbol) bool
- func (r *Renderer) ElementKind(sym *symbols.Symbol) Kind
- func (r *Renderer) KindOf(view *symbols.Symbol) (Kind, string, error)
- func (r *Renderer) Related(sym *symbols.Symbol) []RelatedGroup
- func (r *Renderer) Render(view *symbols.Symbol) (*Rendering, error)
- func (r *Renderer) RenderExposed(exposed []*symbols.Symbol, kind Kind, stated string) (*Rendering, error)
- func (r *Renderer) SetDepth(depth int)
- func (r *Renderer) SetIncluded(included []*symbols.Symbol)
- func (r *Renderer) SetVerdicts(v Verdicts)
- func (r *Renderer) Sites(locate Locator) Sites
- type Rendering
- func (r *Rendering) CSV() (string, error)
- func (r *Rendering) Clone() *Rendering
- func (r *Rendering) D2() (string, error)
- func (r *Rendering) D2With(options Options) (string, error)
- func (r *Rendering) DOT() (string, error)
- func (r *Rendering) DOTWith(options Options) (string, error)
- func (r *Rendering) Data() Data
- func (r *Rendering) DataWith(options Options) Data
- func (r *Rendering) Empty() bool
- func (r *Rendering) EmptyReason() string
- func (r *Rendering) Fills(palette Palette) (map[string]Fill, error)
- func (r *Rendering) Markdown() string
- func (r *Rendering) MarkdownCells(escape func(string) string) string
- func (r *Rendering) Mermaid() string
- func (r *Rendering) MermaidWith(options Options) string
- func (r *Rendering) PlantUML() (string, error)
- func (r *Rendering) PlantUMLWith(options Options) (string, error)
- func (r *Rendering) Positioned() bool
- func (r *Rendering) SVGWith(options Options, animated bool) string
- func (r *Rendering) TSV() (string, error)
- func (r *Rendering) Text() string
- func (r *Rendering) TextWidth(width int) string
- func (r *Rendering) Write(form Form) (string, error)
- func (r *Rendering) WriteWith(form Form, options Options) (string, error)
- type RowData
- type SelectionError
- type SelectionErrorKind
- type Shown
- type Site
- type Sites
- type SourceText
- type Span
- type StateLocator
- func (l *StateLocator) EntryTransition(decl, owner, target ast.Node) (int, bool)
- func (l *StateLocator) Node(vertex ast.Node) (string, bool)
- func (l *StateLocator) Root() string
- func (l *StateLocator) Start(owner ast.Node) (string, bool)
- func (l *StateLocator) Transition(decl, source, target ast.Node) (int, bool)
- type Style
- type UnknownCompartmentsError
- type UnknownDrawingStyleError
- type UnknownElementError
- type UnknownLinesError
- type UnknownPaletteError
- type UnknownPortsError
- type UnknownUnplacedError
- type Unplaced
- type UnsupportedKindError
- type Verdict
- type Verdicts
- type WrongFormError
Constants ¶
const ( MermaidTextCeiling = 1_000_000 MermaidEdgeCeiling = 10_000 )
MermaidTextCeiling and MermaidEdgeCeiling bound the maxTextSize and maxEdges a chart is ever drawn under: twenty times Mermaid's defaults, so a large model's figures draw while no chart asks a browser for unbounded work.
const DefaultAnimationStep = time.Second
DefaultAnimationStep is how long the animated SVG form spends on each step of a run (a timeline instant where a state changes, a message) and on the final state.
const ElementAll = "all"
ElementAll is the name standing for every optional element at once.
const PseudoViewPrefix = "#"
PseudoViewPrefix marks a rendering of exposed elements rather than a declared view.
const ( // WidthUnbounded writes every column as wide as its widest cell, which is // what a form written to a file or a pipe rather than a terminal is. WidthUnbounded = 0 )
The widths the text form is written to.
Variables ¶
var DefaultShown = Shown{ElementPortSymbols: true, ElementCompartments: true, ElementKeywords: true}
DefaultShown is what a rendering shows when neither the model nor the caller says: ports, compartments and keywords, as the notation's examples draw them, and none of the parameter symbols, edge labels, multiplicities, typings and qualifiers. It is the one place the default is decided.
var ErrNotDrawn = fmt.Errorf("behavior not drawn")
ErrNotDrawn reports a behavior a rendering does not draw, so nothing of its execution can be located in it.
var ErrRemotePicture = errors.New("remote pictures are not drawn")
ErrRemotePicture is why a picture located by a URL scheme other than data: is neither drawn nor fetched.
var ErrUnknownCompartments = errors.New("unknown compartment folding")
ErrUnknownCompartments is wrapped by every UnknownCompartmentsError.
var ErrUnknownDrawingStyle = errors.New("unknown drawing style")
ErrUnknownDrawingStyle is a style name that names none. UnknownDrawingStyleError wraps it.
var ErrUnknownElement = errors.New("unknown notation element")
ErrUnknownElement is the sentinel every unknown-element error wraps.
var ErrUnknownLines = errors.New("unknown line routing")
ErrUnknownLines is a routing name that names none. UnknownLinesError wraps it.
var ErrUnknownPalette = errors.New("unknown palette")
ErrUnknownPalette is a palette name that names none. UnknownPaletteError wraps it.
var ErrUnknownPorts = errors.New("unknown port display")
ErrUnknownPorts is a port display name that names none. UnknownPortsError wraps it.
var ErrUnknownUnplaced = errors.New("unknown placement of unplaced nodes")
ErrUnknownUnplaced is a placement name that names none. UnknownUnplacedError wraps it.
var ErrUnsupportedKind = errors.New("unsupported rendering kind")
ErrUnsupportedKind is the rendering kind a view states that this package does not produce. UnsupportedKindError wraps it, so a caller can test for it without knowing which kind was asked for.
var ErrWrongForm = errors.New("rendering is not written in that form")
ErrWrongForm is a form asked for that renderings of the kind are not written in. WrongFormError wraps it.
Functions ¶
func CheckPicture ¶ added in v0.10.0
CheckPicture is nil when the picture at location may be drawn, else why not. data are the bytes of a local file, nil when unread; a data: URL is decoded and checked in their place.
func CompartmentsNames ¶ added in v0.11.0
func CompartmentsNames() string
CompartmentsNames lists the foldings for a usage message.
func DrawingStyleNames ¶ added in v0.9.2
func DrawingStyleNames() string
DrawingStyleNames spells the styles as a list, for help and error text.
func ElementNames ¶ added in v0.11.0
func ElementNames() string
ElementNames lists the element names a switch accepts, "all" last.
func InlineMermaidImages ¶ added in v0.10.0
InlineMermaidImages embeds each readable local flowchart image in source. base is the working directory used to resolve relative image paths.
func LinesNames ¶ added in v0.11.0
func LinesNames() string
LinesNames spells the routings as a list, for help and error text.
func MermaidFits ¶
MermaidFits reports whether a chart's source is drawn under the ceilings.
func MermaidLimits ¶
MermaidLimits is the maxTextSize and maxEdges every one of the sources fits under, which Mermaid's defaults refuse a large chart by, never past the ceilings.
func MermaidSize ¶
MermaidSize is the maxTextSize and maxEdges a chart's source is drawn under: one past its length and one past the edges it declares.
func OverlayNames ¶ added in v0.10.0
func OverlayNames() string
OverlayNames spells the overlays there are, for a message naming them.
func PaletteNames ¶
func PaletteNames() string
PaletteNames spells the palettes as a list, for help and error text.
func ParseDepth ¶ added in v0.11.0
ParseDepth reads a depth option: a non-negative integer, 0 for every level.
func ParseLinkTemplate ¶ added in v0.10.0
ParseLinkTemplate rejects unknown placeholders and an unclosed opening brace.
func PortsNames ¶ added in v0.10.0
func PortsNames() string
PortsNames spells the port displays as a list, for help and error text.
func PseudoViewSpecs ¶
func PseudoViewSpecs() []string
PseudoViewSpecs names the supported pseudo-views in sorted order.
func RemotePictureLocation ¶ added in v0.10.0
RemotePictureLocation reports whether location names a URL scheme other than data:: it holds "://", or starts with an RFC 3986 scheme of two or more characters and ':' (one letter is a Windows drive).
func TableColumns ¶
func TableColumns() []string
TableColumns are the headings a tabular rendering carries when it names none.
func UnplacedNames ¶
func UnplacedNames() string
UnplacedNames spells the placements as a list, for help and error text.
Types ¶
type ActionLocator ¶
type ActionLocator struct {
// contains filtered or unexported fields
}
ActionLocator finds the nodes and edges of a rendering that draw the nodes and successions of a lowered action, the flows of its nested actions included.
func LocateActions ¶
func LocateActions(rendering *Rendering, drawn, action *symbols.Symbol, graph *lower.ActionGraph) (*ActionLocator, error)
LocateActions matches the nodes of graph, lowered from action's declaration, to the root of rendering drawing drawn; keys carry no kind, as an executor's node has none.
func (*ActionLocator) Edge ¶
func (l *ActionLocator) Edge(within []ast.Node, edge lower.ActionEdge) (int, bool)
Edge is the position in the rendering's edges of the succession edge taken in the flow of the nested actions within, false when no edge draws it.
func (*ActionLocator) Node ¶
Node is the ID drawing node in the flow of the nested actions within (outermost first); an undrawn node is placed at the innermost drawn node around it, with false.
func (*ActionLocator) Root ¶
func (l *ActionLocator) Root() string
Root is the ID of the node drawing the action itself.
type Canvas ¶
Canvas is the drawing surface a view states with DiagramLayout::Canvas: its unit, and its extent when HasSize.
type Compartment ¶ added in v0.11.0
type Compartment struct {
// Name is the compartment's name, the plural of the members' keyword as
// the graphical notation heads it: "attributes", "parts", "ports".
Name string
// Rows are the members the compartment lists, each the node it would
// otherwise be drawn as.
Rows []*Node
}
Compartment is one compartment of a node's box: the rows of the members of one kind under the compartment's name, in declaration order.
type Compartments ¶ added in v0.11.0
type Compartments string
Compartments is which members of a tree rendering fold into compartment rows of their owner's box instead of being drawn as nodes of their own.
const ( // CompartmentsPositioned folds only the layout-less members of a // partially positioned tree, the default. CompartmentsPositioned Compartments = "positioned" // CompartmentsMost folds every usage member that nothing keeps a node: // the pilot's COMPMOST style. CompartmentsMost Compartments = "most" // CompartmentsPorts folds port usages alone, each listing the ports nested // under it: the pilot's COMPTREE style. CompartmentsPorts Compartments = "ports" )
func CompartmentsChoices ¶ added in v0.11.0
func CompartmentsChoices() []Compartments
CompartmentsChoices lists the compartment foldings a caller may ask for.
func ParseCompartments ¶ added in v0.11.0
func ParseCompartments(name string) (Compartments, bool)
ParseCompartments reads a folding by name.
type Data ¶
type Data struct {
// View is the rendered view by qualified name, "" for a rendering of exposed
// elements alone (RenderExposed).
View string
// Kind is the rendering produced, and Stated how the kind was decided.
Kind Kind
Stated string
// Run marks a rendering of a run's trace rather than of a view.
Run bool
// RunUntil is the clock instant through which a run rendering was recorded.
RunUntil float64
// Nodes are every node of the rendering, parents before children, each
// naming its parent.
Nodes []NodeData
// Edges join nodes by ID.
Edges []EdgeData
// Columns and Rows are the tabular rendering, empty for every other kind.
Columns []string
Rows []RowData
// Lanes are a run timeline's object machines.
Lanes []Lane
// Canvas is the drawing surface the view states, nil for none.
Canvas *Canvas
// Notes are the note boxes drawn on the canvas, anchored to a node ID or free.
Notes []Note
// Shown names the optional notation elements the rendering draws.
Shown []string
// Notices are what the rendering could not represent and, when it has no
// node, edge, row or lane, why it has none.
Notices []string
}
Data is the machine-consumable shape of a Rendering: the nodes flattened out of the containment tree, the edges between them, the rows of a tabular rendering and what the rendering could not represent. It carries no protocol or wire concern — a caller speaking one converts it.
type DepthError ¶ added in v0.11.0
type DepthError struct {
Value string
}
DepthError is a depth option naming no non-negative integer.
func (*DepthError) Error ¶ added in v0.11.0
func (e *DepthError) Error() string
type Direction ¶
type Direction string
Direction is the flow direction a graph-shaped rendering is drawn in, as Mermaid names them.
func ParseDirection ¶
ParseDirection reports the direction name names, and whether it names one.
type DrawingStyle ¶ added in v0.9.2
type DrawingStyle string
DrawingStyle names the look the DOT and Mermaid forms draw a diagram in: the Pilot "Standard B&W" default, or the look of a diagram drawn by Cameo Systems Modeler, for a document migrated from one. A style is independent of the palette: a palette recolours the nodes of whichever style is drawn.
const ( // StylePilot is the Pilot "Standard B&W" look: Helvetica text, white // fills, thin #181818 lines, no diagram frame. The empty style is this one. StylePilot DrawingStyle = "pilot" // StyleCameo is the look of a Cameo Systems Modeler diagram: a frame with // the `kind [Type] Owner [ Name ]` header tab, Arial text, the pale yellow, // green and orange gradient fills Cameo gives states, actions and blocks, // thin dark borders, and notes with a folded corner and a dashed anchor. StyleCameo DrawingStyle = "cameo" )
func DrawingStyles ¶ added in v0.9.2
func DrawingStyles() []DrawingStyle
DrawingStyles are the styles the DOT and Mermaid forms can be asked for, in the order they are offered.
func ParseDrawingStyle ¶ added in v0.9.2
func ParseDrawingStyle(name string) (DrawingStyle, bool)
ParseDrawingStyle reports the style name names, and whether it names one. The empty name is the default, StylePilot.
type Drawn ¶
type Drawn struct {
// contains filtered or unexported fields
}
Drawn is what one rendering of a view draws: the elements it positions as nodes and those it steers as edges, by their declarations; a member drawn as an owner's — the start or done a body inherits — by the owner as well.
func (*Drawn) MemberNode ¶ added in v0.9.2
MemberNode reports whether the rendering draws sym as a node of owner's: one element inherited by many bodies is drawn once per body, and a Layout naming it as one inheriting owner's positions that body's alone. One naming it as the declaring owner's positions every body's, as a member the rendering draws as no owner's in particular is drawn for every owner.
type Edge ¶
type Edge struct {
// From and To are node IDs.
From string
To string
// FromPort and ToPort are the IDs of the ports of From and To the edge ends
// at, empty where it ends at the node itself.
FromPort string
ToPort string
// Label is what the edge carries: a connector's name, a transition's
// trigger, guard and effect, a succession's guard, a flow's pins. It may be empty.
Label string
// FromLabel and ToLabel name the edge's ends — the association or
// connector end at From and the one at To, a composite part usage's name
// and multiplicity on the composition to its type — drawn beside that end,
// not along the edge; empty for an unnamed end.
FromLabel string
ToLabel string
// Name is the edge's own name, for a writer whose drawing shows the rest
// of its Label another way; empty for one anonymous or named by a migration.
Name string
Kind EdgeKind
// Origin is where the connection, transition, succession or flow was
// declared, the zero Origin for one with no locatable declaration.
Origin Origin
// Route is the waypoints the edge follows, from the Route annotation of the
// element it was declared as; empty leaves the routing to the writer.
Route []Point
// Style is how the edge is drawn, from the Style annotation colouring it;
// nil leaves the look to the drawing style.
Style *Style
// contains filtered or unexported fields
}
Edge joins two nodes of a rendering.
type EdgeData ¶
type EdgeData struct {
From string
To string
// FromPort and ToPort are the ports the edge ends at, "" for the node itself.
FromPort string
ToPort string
// Label is the edge's own text; FromLabel and ToLabel name its ends, drawn
// beside them, "" for an unnamed end.
Label string
FromLabel string
ToLabel string
// Name is the edge's own name, "" for one anonymous or named by a migration.
Name string
Kind EdgeKind
Origin Origin
// Route is the waypoints the edge follows, empty when no Route gives any.
Route []Point
// Style is how the edge is drawn, nil when no Style colours it.
Style *Style
}
EdgeData is one edge of a rendering, joining two node IDs.
type EdgeKind ¶
type EdgeKind int
EdgeKind classifies what an edge of a rendering stands for.
const ( // EdgeConnection is a connector joining two features. EdgeConnection EdgeKind = iota // EdgeTransition is a state transition. EdgeTransition // EdgeSuccession is a succession between action nodes. EdgeSuccession // EdgeFlow is a flow of a payload between action nodes. EdgeFlow // EdgeBinding is a binding equating two features. EdgeBinding // EdgeSpecialization is a specialization, subsetting or redefinition, from // the specific element to the general one. EdgeSpecialization // EdgeTyping is a feature typing, from a usage to its definition. EdgeTyping // EdgeComposition is a composite usage, from its owner to it; in a case // diagram, a case contained in another. EdgeComposition // EdgeReference is a referential usage, from its owner to it; in a case or // mixed diagram, a performing or exhibiting usage to its target. EdgeReference // EdgeContainment is a package owning another, from the owner. EdgeContainment // EdgeImport is a package's import, from the importing package. EdgeImport // EdgeSatisfy is a satisfy relationship, from the satisfying element. EdgeSatisfy // EdgeVerify is a verification case verifying a requirement. EdgeVerify // EdgeDerive is a requirement derivation, from the derived requirement. EdgeDerive // EdgeRefine is a refinement dependency, from the refining element. EdgeRefine // EdgeAllocate is an allocation, from the allocated element. EdgeAllocate // EdgeAssociation is an association drawn as a plain line: an actor or subject // to a case, or a connection def between the definitions typing its two ends. EdgeAssociation // EdgeInclude includes one case in another. EdgeInclude // EdgeAnchor attaches an objective to a case. EdgeAnchor )
type Element ¶ added in v0.11.0
type Element string
Element is a notation element the SysML v2 graphical notation makes optional, which a rendering shows or leaves out by name.
const ( // ElementParameterSymbols are the symbols on a node's boundary standing for // its parameters: a case's actor, subject and stakeholder parameters and an // action's parameter pins (SysML v2 §7.26.5 and the distinguished-parameter // alternatives of §8.2.3). Left out, a connection that ended at the // parameter ends at the node declaring it. ElementParameterSymbols Element = "parameter-symbols" // ElementPortSymbols are the port symbols on a part's boundary (§7.26.5, // "can include symbols on the boundary of the node to represent ports"). // Left out, a connection that ended at a port ends at the part owning it. ElementPortSymbols Element = "port-symbols" // ElementCompartments are the compartments under a node's name: the lines // a node's label carries after its title (§7.26.5, "can include compartments"). ElementCompartments Element = "compartments" // ElementEdgeLabels are the names connections, interfaces, flows, bindings // and allocations are labelled with (§8.2.3, the optional name of a // connection-link and flow-link). ElementEdgeLabels Element = "edge-labels" // ElementKeywords are the «keyword» lines heading a node (§8.2.3, the // optional keyword of a node's name-compartment). ElementKeywords Element = "keywords" // ElementMultiplicities are the `[n]` multiplicities after a usage's name // (§8.2.3, the optional multiplicity of a feature-declaration). ElementMultiplicities Element = "multiplicities" // ElementTypings are the `: Type` texts after a usage's name and a port's // (§8.2.3, the optional feature-typing of a feature-declaration). ElementTypings Element = "typings" // ElementQualifiers are the qualifying prefixes of a node's name (§8.2.3, // a name may be written qualified or not). ElementQualifiers Element = "qualifiers" )
func ElementOfAttribute ¶ added in v0.11.0
ElementOfAttribute is the element a rendering's Boolean attribute switches, by the attribute's name; false for a name switching none.
type Fill ¶
Fill is the colours a palette gives one node, `#RRGGBB`: the fill of its box, and the border, the family colour the fill is tinted from — empty for a sequence participant, whose outline keeps the black-and-white rules.
type Form ¶
type Form string
Form is a written form of a rendering: the human-readable text every kind has, the machine-readable form of the kind — a Mermaid diagram for graph-shaped kinds, a Markdown table for tabular kinds — the Graphviz DOT, PlantUML and D2 forms a graph-shaped kind can be asked for instead, and the CSV and TSV forms a tabular kind can.
const ( // FormText is the human-readable form, which the REPL prints. FormText Form = "text" // FormMermaid is a Mermaid diagram of a graph-shaped rendering. FormMermaid Form = "mermaid" // FormMarkdown is a Markdown table of a tabular rendering. FormMarkdown Form = "markdown" // FormDot is a Graphviz DOT digraph of a graph-shaped rendering. FormDot Form = "dot" // FormPlantUML is a PlantUML diagram of a graph-shaped or sequence rendering. FormPlantUML Form = "plantuml" // FormD2 is a D2 diagram of a graph-shaped or sequence rendering. FormD2 Form = "d2" // FormCSV is comma-separated values of a tabular rendering. FormCSV Form = "csv" // FormTSV is tab-separated values of a tabular rendering. FormTSV Form = "tsv" // FormSVG is a self-contained SVG drawing of a run: a timeline's lanes and // state spans on a time axis, or a sequence's lifelines and messages. FormSVG Form = "svg" // FormSVGAnimated is the SVG form replaying the run with SMIL animation. FormSVGAnimated Form = "svg-animated" )
func DiagramForms ¶
func DiagramForms() []Form
DiagramForms are the forms a document render writes its graph-shaped diagrams as; a tabular view is written as a table whichever is chosen.
func Forms ¶
func Forms() []Form
Forms are the forms a rendering can be asked for, in the order they are offered.
func ViewForms ¶ added in v0.11.0
func ViewForms() []Form
ViewForms are the forms a model view is written in: every form but the run-only SVG forms, which draw a recorded run and no model view.
func (Form) TakesPalette ¶
TakesPalette reports whether the form fills nodes from a palette.
func (Form) TakesStyle ¶ added in v0.9.2
TakesStyle reports whether the form draws a diagram in a DrawingStyle.
type Geometry ¶
type Geometry struct {
X, Y float64
Width, Height float64
// Unplaced marks a Layout stating no x and y, one that only folds or hides
// and leaves the node for the form to lay out.
Unplaced bool
HasSize bool
Collapsed bool
Hidden semantics.HiddenCompartments
}
Geometry is where a node is drawn, from the DiagramLayout::Layout positioning it in the rendered view; HasSize says whether Width and Height were given. Hidden are the compartments the Layout's show… switches turn off for this symbol, which its box neither lists nor counts as clipped.
type Kind ¶
type Kind string
Kind is a rendering a view can state. The kinds this package produces are tree, interconnection, state, action, case, mixed, table, matrix, sequence and the requirement, definition and package graphs a filtered GeneralView presents; the rest are recognized so that a view stating one is told it is unsupported rather than rendered as something else. A rendering the standard library does not declare is carried as the name the model gives it, so an error about it names what the view asked for.
const ( // KindTree renders the exposed elements as a containment tree. KindTree Kind = "tree" // KindInterconnection renders exposed features as nodes and the connections // between them as edges. KindInterconnection Kind = "interconnection" // KindState renders the states and transitions of exposed behaviors. KindState Kind = "state" // KindAction renders the nodes and successions of exposed behaviors. KindAction Kind = "action" // KindCase names SysML's CaseDefinition/CaseUsage family; "usecase" would // mislabel analysis and verification cases. KindCase Kind = "case" // KindMixed combines behavioral, case, structural, and tree content on one canvas. KindMixed Kind = "mixed" // KindTextual is Views::asTextualNotation, which writes the model back as // notation: `sysml -convert sysml` does that, so no rendering is produced. KindTextual Kind = "textual" // KindTable renders the exposed elements as rows of a table, which is // Views::asElementTable and an unfiltered StandardViewDefinitions::GridView. KindTable Kind = "table" // KindMatrix renders the relationships selected by a filtered GridView. KindMatrix Kind = "matrix" // KindSequence renders exposed occurrences as lifelines and the flows // between them as ordered messages, which is // StandardViewDefinitions::SequenceView. KindSequence Kind = "sequence" // KindTimeline renders a run's trace as each object machine's states over // clock time; no view states it. KindTimeline Kind = "timeline" // KindGeometry is StandardViewDefinitions::GeometryView. KindGeometry Kind = "geometry" // KindRequirement renders exposed requirements as nodes and the // relationships between them and what satisfies, verifies, derives, refines // or is allocated to them as edges: a GeneralView filtered to requirements. KindRequirement Kind = "requirement" // KindDefinition renders exposed definitions and usages as nodes and their // specialization, typing, composition and reference as edges: a GeneralView // filtered to definitions and usages. KindDefinition Kind = "definition" // KindPackage renders exposed packages as nodes and their containment and // imports as edges: a GeneralView filtered to packages. KindPackage Kind = "package" )
func Kinds ¶
func Kinds() []Kind
Kinds returns every rendering kind this package recognizes, supported or not.
func ParsePseudoView ¶
ParsePseudoView parses #<kind> or #<kind>:<target>.
func PseudoViewKind ¶
PseudoViewKind reports the supported rendering kind named by name.
func (Kind) GraphShaped ¶ added in v0.10.0
GraphShaped reports whether k is drawn as a graph of nodes and edges: every produced kind that is not tabular, the kinds a document's diagrams and the DOT, Mermaid, PlantUML and D2 forms draw.
func (Kind) MachineForm ¶
MachineForm is the machine-readable form of renderings of this kind.
func (Kind) SupportedForms ¶
SupportedForms are the forms renderings of the kind are written in, in the order Forms offers them.
func (Kind) SupportsDirection ¶
SupportsDirection reports whether a rendering of the kind is drawn as a graph a direction can be stated for: a flowchart or a state diagram. A table has no direction, and a sequence diagram always reads top-down.
func (Kind) SupportsForm ¶
SupportsForm reports whether renderings of the kind are written in form: every kind has the text form and its machine form; tree, interconnection, state, action, case, mixed, requirement, definition and package have DOT and PlantUML, tree, interconnection, state, action, requirement, definition and package also have D2, sequence has PlantUML and D2, and tabular kinds (table and matrix) have CSV and TSV.
func (Kind) SupportsOverlay ¶ added in v0.10.0
SupportsOverlay reports whether a rendering of the kind draws o: verdicts are drawn on a requirement rendering alone.
func (Kind) SupportsPalette ¶
SupportsPalette reports whether a rendering of the kind is drawn as nodes a palette can fill: the kinds a form that fills nodes is written for.
func (Kind) SupportsPorts ¶ added in v0.10.0
SupportsPorts reports whether a rendering of the kind draws a part's ports, which the Ports display chooses among: interconnection and mixed renderings.
type Lane ¶ added in v0.10.0
type Lane struct {
ID string
Name string
// Origin is where the lane's state machine was declared.
Origin Origin
Spans []Span
Transitions []LaneTransition
Marks []Mark
}
Lane is one object machine in a run timeline.
type LaneTransition ¶ added in v0.10.0
LaneTransition is a transition recorded at an instant in a lane.
type Lines ¶ added in v0.11.0
type Lines string
Lines is how a graph-shaped form routes its edges, where the form's engine takes a routing: Graphviz's `splines` on the DOT form and PlantUML's `linetype`, the two routings the Pilot visualizer's ORTHOLINE and POLYLINE styles ask for. The empty Lines is LinesSplines.
const ( // LinesSplines leaves each engine its default, curved routing. The default. LinesSplines Lines = "splines" // LinesOrtho routes every edge as axis-parallel segments, as the Pilot's // ORTHOLINE style does. LinesOrtho Lines = "ortho" // LinesPolyline routes every edge as straight segments, as the Pilot's // POLYLINE style does. LinesPolyline Lines = "polyline" )
func LinesChoices ¶ added in v0.11.0
func LinesChoices() []Lines
LinesChoices are the routings a rendering can be asked for, the default first.
func ParseLines ¶ added in v0.11.0
ParseLines reports the routing name names, and whether it names one. The empty name is the default, LinesSplines.
type Links ¶ added in v0.10.0
Links is a link template and its source sites; the zero value writes none.
type Locator ¶ added in v0.10.0
Locator places a located origin in its source file; ok is false when no on-disk source location is available.
type Node ¶
type Node struct {
// ID identifies the node within its rendering, and is what an edge names.
ID string
// Kind is what the notation calls the element — "part def", "state",
// "fork" — never a Go type name.
Kind string
// Name is the element's name: qualified for a node the view exposes, simple
// for one nested in it. It is empty for an anonymous element.
Name string
// NameSynthesized marks a name the model did not give: a migration made it up, or
// it is the language's `start`/`done`. A name to key by, not one a picture shows.
NameSynthesized bool
// Referential marks a structural usage that refers to its value rather
// than owning it (`ref part`): a row of a tool's references compartment.
Referential bool
// StandIn marks a node a migration made up that stands for no element of its
// source, so no diagram symbol is at it: a join it wrote several edges through.
StandIn bool
// Type is the declared type of a typed usage, as the notation writes it
// after the colon. It is empty for a definition or an untyped usage.
Type string
// Typings are the qualified names of the elements Type resolves to, in its
// order; a member of one is drawn as the type's own. Empty when none resolves.
Typings []string
// Detail is what else the rendering says about the node, such as a state's
// "initial" or "already shown". It is empty when there is nothing to add.
Detail string
// Value is the value a usage is bound to, as the notation writes it after
// the `=`. It is empty for a definition or an unbound usage.
Value string
// Compartments are the members drawn as rows inside the node's box rather
// than as nodes of their own, grouped by kind in the notation's compartment
// order: in a positioned tree, the members with no position. Nil when
// every member is a node.
Compartments []Compartment
// Text is what heads a node whose name is not shown, in place of its kind:
// the literal a value specification's result is bound to, the event an
// accept waits for, the message a send sends. Empty when its kind heads it.
Text string
// Children are the nodes nested in this one.
Children []*Node
// Ports are the features drawn on the node's border, an action's pins, which
// an edge may end at instead of the node itself.
Ports []Port
// Origin is where the element was declared, the zero Origin for one with no
// locatable declaration.
Origin Origin
// Inherited is where the declarations a drawn behavior took content from besides
// its own were written (what it specializes or is typed by); only a root has them.
Inherited []Origin
// Geometry is where the element is drawn, from the Layout annotation that
// positions it in this view; nil leaves the placement to the writer.
Geometry *Geometry
// Style is how the element is drawn, from the Style annotation colouring it
// in this view, or from its verdict; nil leaves the look to the drawing style.
Style *Style
// Verdict is the worst verdict of the verification cases verifying a
// requirement, when the rendering overlays them: pass, inconclusive, fail or
// error. Empty when none is overlaid.
Verdict string
// contains filtered or unexported fields
}
Node is one element of a rendering: an exposed element, a feature nested in one, a state or an action node, or the "start" of a state body, which its entry transitions leave. Children are the nodes nested in it, which is how a rendering carries containment.
type NodeData ¶
type NodeData struct {
ID string
Kind string
Name string
// NameSynthesized marks a Name the model did not give: a name to key by, not one a picture shows.
NameSynthesized bool
Type string
Detail string
// Text heads a node whose name is not shown, in place of its kind: a value
// specification's literal, an accept's event, a send's message.
Text string
// StandIn marks a node a migration made up that stands for no element of its
// source, which a positioned drawing may elide.
StandIn bool
// Ports are the pins drawn on the node's border, which an edge may end at.
Ports []Port
// Parent is the ID of the node this one is nested in, "" for a root.
Parent string
// Compartment names the compartment of Parent this node is a row of, ""
// for a node drawn as a box of its own.
Compartment string
Origin Origin
// Geometry is where the node is drawn, nil when no Layout positions it.
Geometry *Geometry
// Style is how the node is drawn, nil when no Style colours it.
Style *Style
// Verdict is the worst verification verdict overlaid on a requirement, ""
// when none is.
Verdict string `json:",omitempty"`
}
NodeData is one node of a rendering, with the node it is nested in.
type Note ¶ added in v0.9.2
type Note struct {
Text string
Anchor string
EdgeFrom string
EdgeTo string
X, Y float64
Width, Height float64
HasSize bool
Origin Origin
}
Note is a note box drawn on the canvas, from a DiagramLayout::Note: its text, the node it is anchored to (or the edge, by its end nodes; neither for one free on the surface), the top-left corner of its box and its size when HasSize. Origin is where the Note annotation is stated: one annotation `about` several elements yields a Note per element, all of one Origin, drawn as one box.
type Options ¶
type Options struct {
// Links is the source link each node and edge is written with; zero writes none.
Links Links
// Direction is the flow direction a graph-shaped form is drawn in; empty
// leaves each kind's default.
Direction Direction
// Palette is the palette the DOT, Mermaid, PlantUML and D2 forms fill nodes
// from, by keyword family; empty draws in black and white.
Palette Palette
// Ports is how much of a part's ports an interconnection or mixed rendering
// draws; empty draws the connected ones, as PortsMinimal does.
Ports Ports
// Style is the look the DOT and Mermaid forms draw in; empty is the Pilot's, StylePilot.
Style DrawingStyle
// Unplaced is what a graph-shaped form does with the nodes a positioned
// drawing leaves unplaced; empty leaves them undrawn, as UnplacedOmit does.
Unplaced Unplaced
// Compartments is which members of a tree fold into compartment rows of
// their owner; empty folds the unplaced members of a positioned tree alone,
// as CompartmentsPositioned does.
Compartments Compartments
// Width is the width the text form is written to fit; WidthUnbounded
// writes every column as wide as its widest cell.
Width int
// Lines is how the DOT and PlantUML forms route their edges; empty leaves
// each engine's curved default, as LinesSplines does.
Lines Lines
// Show is the optional notation elements drawn besides those the rendering
// shows of itself (its Shown, the model's choice or DefaultShown); nil adds none.
Show Shown
// AnimationStep is how long the animated SVG form spends on each step of a
// run; zero is DefaultAnimationStep.
AnimationStep time.Duration
}
Options are what a rendering is written with beside its form. Each form takes the ones that apply to it: the text form its Width, Mermaid, DOT, PlantUML and D2 their Direction, Palette, Style and Unplaced, DOT and PlantUML their Lines routing, and the interconnection and mixed forms their Ports display. A form ignores the rest.
type Overlay ¶ added in v0.10.0
type Overlay string
Overlay is what a rendering draws over the model's structure; "" draws none.
const OverlayVerdicts Overlay = "verdicts"
OverlayVerdicts runs the verification cases verifying each requirement of a requirement rendering and colours and labels the requirement by their verdicts.
func ParseOverlay ¶ added in v0.10.0
ParseOverlay is the overlay named; "" is none, which is valid.
type Palette ¶
type Palette string
Palette names the set of fill colours the DOT, Mermaid, PlantUML and D2 forms colour nodes with, one per keyword family (part, item, port, …, see paletteFamilies). Mermaid sequence diagrams report that they cannot fill individual participants. The empty Palette is the black-and-white default; every named one is colourblind-safe.
const ( // PaletteOkabeIto is the eight-colour palette of Okabe & Ito, "Color // Universal Design" (2002, jfly.uni-koeln.de/color). PaletteOkabeIto Palette = "okabe-ito" // PaletteTolBright, PaletteTolMuted and PaletteTolLight are Paul Tol's // qualitative schemes (personal.sron.nl/~pault, technical note 3.2, 2021). PaletteTolBright Palette = "tol-bright" PaletteTolMuted Palette = "tol-muted" PaletteTolLight Palette = "tol-light" // PaletteBrewerSet2 and PaletteBrewerDark2 are ColorBrewer's Set2 and // Dark2 (Cynthia Brewer, colorbrewer2.org; Apache-2.0, notice below). PaletteBrewerSet2 Palette = "brewer-set2" PaletteBrewerDark2 Palette = "brewer-dark2" // PaletteViridis and PaletteCividis are sequential ramps, sampled at 16 // stops of matplotlib's colour maps (van der Walt & Smith; Nuñez, Anderton // & Renslow 2018), darkest first. PaletteViridis Palette = "viridis" PaletteCividis Palette = "cividis" )
func Palettes ¶
func Palettes() []Palette
Palettes are the palettes a rendering can be asked for, in the order they are offered.
func ParsePalette ¶
ParsePalette reports the palette name names, and whether it names one. The empty name is no palette: the black-and-white default is asked for by stating none.
func (Palette) Color ¶
Color is the palette's colour for category i of n, `#RRGGBB`: a qualitative palette's i-th colour, wrapping round past its last, or a sequential ramp sampled evenly over its stops with category 0 the darkest.
func (Palette) Sequential ¶
Sequential reports whether the palette is a ramp sampled to fit the categories drawn, rather than a fixed set of distinct colours.
type Picture ¶ added in v0.9.2
type Picture struct {
Location string
Dir string
X, Y float64
Width, Height float64
Alt string
Above bool
}
Picture is a DiagramLayout::Picture drawn on the canvas: its file as the view states it, the view's directory ("" in no file), its box, alt text, and z-order.
type PilotStyle ¶ added in v0.10.0
type PilotStyle string
PilotStyle is a style name the OMG pilot kernel's %viz accepts that no form here draws: a PlantUML line routing, a compartment layout, a visibility switch of the pilot's own visualizer. Such a style is accepted so a notebook written for the pilot runs, and is reported as not represented so it is not dropped silently.
func ParsePilotStyle ¶ added in v0.10.0
func ParsePilotStyle(name string) (PilotStyle, bool)
ParsePilotStyle reports the pilot style name names, in any letter case, and whether it names one.
func PilotStyles ¶ added in v0.10.0
func PilotStyles() []PilotStyle
PilotStyles are the pilot's undrawn style names in alphabetical order, as the pilot spells them.
func (PilotStyle) Notice ¶ added in v0.10.0
func (s PilotStyle) Notice() string
Notice is what a rendering reports for a pilot style it was asked for and does not draw.
type Point ¶
type Point struct {
X, Y float64
}
Point is one position on a rendering's canvas, in pixels from the top-left corner, y increasing downward.
type Port ¶ added in v0.9.2
type Port struct {
// ID identifies the port within its rendering, and is what an edge names.
ID string
// Name is the pin's name, as the notation writes it.
Name string
// NameSynthesized marks a name the model did not give, which a form
// leaves off the pin's label as it does off a node's.
NameSynthesized bool
// Type is the port's declared type as the notation writes it, `~T` for a
// conjugated one; empty for a pin, whose type the flow's label carries.
Type string
// Direction is the pin's direction: `in`, `out` or `inout`; PortUndirected
// for a part's port, whose features carry the directions.
Direction PortDirection
// Parameter marks a pin standing for a parameter — a case's subject or
// attribute, an action's pin — rather than for a port the part declares.
Parameter bool
// Origin is where the pin was declared, the zero Origin for one with no
// locatable declaration.
Origin Origin
// Geometry is where the pin is drawn, from the Layout annotation that
// positions it in this view; nil leaves the placement to the writer.
Geometry *Geometry `json:",omitempty"`
// Exposed marks a pin the view exposes in its own right, drawn whatever
// the display shows of the other pins.
Exposed bool `json:",omitempty"`
}
Port is a feature drawn on a node's border: an input or output pin of an action, which an object flow ends at, or a port a part has from its definition, which a connector ends at.
type PortDirection ¶ added in v0.9.2
type PortDirection int
PortDirection is which way a port's values flow.
const ( // PortIn takes values in. PortIn PortDirection = iota // PortOut gives values out. PortOut // PortInOut does both. PortInOut // PortUndirected has no direction of its own: a part's port. PortUndirected )
func (PortDirection) String ¶ added in v0.9.2
func (d PortDirection) String() string
String writes a port direction as the notation does, "" for none.
type Ports ¶ added in v0.10.0
type Ports string
Ports is how much of a part's ports an interconnection or mixed rendering draws. The empty Ports is PortsMinimal.
const ( // PortsMinimal draws the ports a connector of the view ends at and no // other, each a small square on its part's border named beside it, so a // crowded diagram shows what it connects and nothing more. The default. PortsMinimal Ports = "minimal" // PortsFull draws every port a part has, labelled `name : Type`. PortsFull Ports = "full" )
func ParsePorts ¶ added in v0.10.0
ParsePorts reports the display name names, and whether it names one. The empty name is the default, PortsMinimal.
func PortsChoices ¶ added in v0.10.0
func PortsChoices() []Ports
PortsChoices are the port displays a rendering can be asked for, the default first.
type RelatedGroup ¶ added in v0.11.0
type RelatedGroup struct {
Kind RelatedKind
// Label says what the group holds, for a client listing it.
Label string
// Elements are the named related elements in model order, each once, never
// the element itself and never a standard library element: those are what
// a rendering draws when a view exposes them.
Elements []*symbols.Symbol
}
RelatedGroup is the elements one kind of relationship relates an element to.
type RelatedKind ¶ added in v0.11.0
type RelatedKind string
RelatedKind names one kind of relationship Related groups elements by; the names are what a client asks a rendering to include elements by.
const ( // RelatedGeneralizations are the elements sym specializes, subsets or redefines. RelatedGeneralizations RelatedKind = "generalizations" // RelatedSpecializations are the elements specializing, subsetting or redefining sym. RelatedSpecializations RelatedKind = "specializations" // RelatedTypes are the definitions typing sym. RelatedTypes RelatedKind = "types" // RelatedTypedUsages are the usages sym types. RelatedTypedUsages RelatedKind = "typedUsages" // RelatedOwner is the element declaring sym. RelatedOwner RelatedKind = "owner" // RelatedOwnedMembers are the elements sym declares. RelatedOwnedMembers RelatedKind = "ownedMembers" // RelatedConnections are the elements connectors join sym to. RelatedConnections RelatedKind = "connections" // RelatedFlows are the elements flows join sym to. RelatedFlows RelatedKind = "flows" // RelatedBindings are the elements bindings join sym to. RelatedBindings RelatedKind = "bindings" // RelatedSuccessions are the actions sym's successions reach or leave. RelatedSuccessions RelatedKind = "successions" )
func RelatedKinds ¶ added in v0.11.0
func RelatedKinds() []RelatedKind
RelatedKinds lists every kind Related groups by, in listing order.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer renders views over one semantic model.
func NewRenderer ¶
NewRenderer returns a renderer over the model and resolver of a loaded document. text may be nil.
func (*Renderer) DefaultKind ¶ added in v0.10.0
DefaultKind chooses the rendering kind a set of elements is drawn in when none is asked for: the kind each element calls for, and KindMixed when they disagree. An element asks for a state rendering when it is a state def or usage, an action rendering when it is an action def or usage, a case rendering when it is a case def or usage of any kind, an interconnection rendering when it is a structural usage holding a connector, binding or flow, and a tree rendering otherwise — a definition, a package or a usage with no connections to draw. An empty set is a tree.
func (*Renderer) DrawnIn ¶
DrawnIn renders view and reports what the rendering draws: the elements a Layout or Route stated in the view's body can apply to. A view that does not render is the error Render gives.
func (*Renderer) DrawsAnywhere ¶
DrawsAnywhere reports whether some rendering kind draws sym as a node and whether some draws it as an edge: what an annotation applying in every view can position.
func (*Renderer) DrawsSpecializationAnywhere ¶ added in v0.11.0
DrawsSpecializationAnywhere reports whether some rendering draws an edge from sym to general: the tree draws one for each specialization, typing or subsetting between two elements it draws as nodes.
func (*Renderer) ElementKind ¶ added in v0.10.0
ElementKind is the rendering kind one element calls for; see DefaultKind.
func (*Renderer) KindOf ¶
KindOf reports the rendering kind a view states and how it states it: the rendering its body names, else the standard view definition it specializes, else the tree every view defaults to. A recognized kind this package does not produce is an *UnsupportedKindError.
func (*Renderer) Related ¶ added in v0.11.0
func (r *Renderer) Related(sym *symbols.Symbol) []RelatedGroup
Related groups the model's own elements related to sym by the relationships a rendering draws edges for: its generalizations and specializations, its types and the usages it types, its owner and owned members, the elements connectors, flows and bindings join it to, and the actions its successions reach or leave. Empty groups are left out. A state's transitions are not a group: a state nested in its machine is drawn only within the machine, so including the states a transition joins draws nothing of their own.
func (*Renderer) Render ¶
Render renders view in the kind it states, defaulting to a tree when it states none. A view that is no view is semantics.ErrNotAView, and a recognized kind this package does not produce is an *UnsupportedKindError — never another kind's rendering.
func (*Renderer) RenderExposed ¶
func (r *Renderer) RenderExposed(exposed []*symbols.Symbol, kind Kind, stated string) (*Rendering, error)
RenderExposed renders elements in the kind asked for, as a view exposing just them would: a document with no view declared is rendered this way. Nothing is added to the model or to the symbol index, so the rendering carries no view name; stated says how the kind was decided. An unsupported kind is an *UnsupportedKindError.
func (*Renderer) SetDepth ¶ added in v0.11.0
SetDepth overrides the depth every view states for the renders that follow: each exposed element is drawn with depth levels of nested elements below it. 0 restores the model's say.
func (*Renderer) SetIncluded ¶ added in v0.11.0
SetIncluded names elements every rendering draws besides what its view exposes, as if the view exposed them too; nil draws the view's own content.
func (*Renderer) SetVerdicts ¶ added in v0.10.0
SetVerdicts overlays each requirement of a requirement rendering with the verdicts v answers; nil, the default, draws the rendering structurally.
type Rendering ¶
type Rendering struct {
// View is the rendered view, by qualified name as the notation writes it.
View string
// Kind is the rendering produced.
Kind Kind
// Stated is how the kind was decided: the rendering member the view states,
// the standard view definition it specializes, or "" when the view states
// nothing and the default was used.
Stated string
// Run marks a rendering of a run's trace rather than of a view.
Run bool
// RunUntil is the clock instant through which a run rendering was recorded.
RunUntil float64
// Roots are the top-level nodes, in the order the view exposes them.
Roots []*Node
// Edges join nodes, in the order the model and the lowered graphs give them.
Edges []Edge
// Columns are the headings of a tabular rendering, empty for every other
// kind.
Columns []string
// Rows are the rows of a tabular rendering, each holding one cell per
// column, in the order the view exposes the elements.
Rows [][]string
// Lanes are a timeline's object machines, in the order the run first
// recorded them.
Lanes []Lane
// RowOrigins is where each row's element was declared, one entry per row.
RowOrigins []Origin
// Shown is the optional notation elements the view's rendering shows, read
// from the rendering the view states; nil is DefaultShown.
Shown Shown
// Canvas is the drawing surface the view states, nil for a view stating
// none.
Canvas *Canvas
// Notes are the note boxes drawn on the canvas, anchored to a node or free,
// in the order the nodes they annotate are drawn, free ones last.
Notes []Note
// Pictures are the pictures drawn on the canvas, in the order the view
// states them; a later one is drawn over an earlier one it overlaps.
Pictures []Picture
// Notices are what the rendering could not represent, reported rather than
// dropped: an exposed element with no place in this kind of rendering, a
// connection to something the view does not expose, a behavior that does not
// lower.
Notices []string
// Included is where each element drawn by SetIncluded rather than by the
// view was declared, in the order the renderer was given them.
Included []Origin
// contains filtered or unexported fields
}
Rendering is what a view or run renders to. It is a value, not a live view of the model: nothing in it points back into the AST.
func RenderNamed ¶ added in v0.10.0
func RenderNamed(renderer *Renderer, name string, lookup func(string) []*symbols.Symbol) (*Rendering, error)
RenderNamed resolves a declared view or targeted pseudo-view and renders it. lookup resolves a qualified name in the caller's model index.
func (*Rendering) CSV ¶ added in v0.10.0
CSV is a tabular rendering as comma-separated values: the columns as a header record, then one record per row, each field quoted as RFC 4180 quotes it.
func (*Rendering) Clone ¶
Clone returns a deep copy of the rendering, so a holder can hand it out without letting its nodes or rows be changed underneath it.
func (*Rendering) D2 ¶ added in v0.10.0
D2 is the D2 form of a graph-shaped or sequence rendering, in black and white with each kind's default direction.
func (*Rendering) D2With ¶ added in v0.10.0
D2With is the rendering as a D2 diagram, drawn as the DOT and PlantUML forms draw: a tree as flat nodes joined by containment lines, an interconnection as nested containers whose drawn ports are pins inside them, a state or action graph as nested containers with its control nodes as pseudostate glyphs, a requirement, definition or package graph as nodes joined in the class-diagram notation, and a sequence as D2's sequence diagram. Direction, Palette, Ports and Unplaced apply; a Style does not, D2 drawing in one look, and asking for one is noticed. Positions and routes are kept as comments, D2 laying the diagram out itself.
func (*Rendering) DOT ¶
DOT is the Graphviz form of a graph-shaped rendering: a `digraph`, written as text like the Mermaid form, with no Graphviz installed. A node with children is a `subgraph "cluster_<id>"` (a tree draws containment as edges, as its Mermaid form does) holding an invisible anchor node `"<id>"`, so an edge keeps the rendering's endpoints and is clipped at the cluster with `lhead`/`ltail` — except at an end that encloses the other, where the edge starts or ends inside it. Edge kinds parallel the Mermaid arrows:
EdgeKind Mermaid DOT EdgeConnection --- arrowhead=none EdgeTransition --> solid, default arrowhead EdgeSuccession --> solid, default arrowhead EdgeFlow -.-> style=dashed EdgeBinding --- arrowhead=none (containment) --- arrowhead=none
DiagramLayout geometry is written as Graphviz reads it (pinned `pos`, `bb`, `pos` splines, pinned canvas corners); docs/project/view-rendering-forms.md#geometry has the rules. A drawing some Layout positions leaves the nodes none does undrawn, or sets them in a strip below it when asked (Options.Unplaced).
The drawing is in the Standard B&W style of the SysML v2 Pilot visualizer (docs/project/view-rendering-forms.md#style): Helvetica, white fills, thin #181818 lines, square definitions and rounded usages, the keyword line in italics. Defaults are written once as `graph`, `node` and `edge` statements; a node or edge states only what it deviates in, its style before its geometry. Options.Style draws the Cameo look instead (StyleCameo); a node's or edge's own Style annotation wins over either, and notes are `shape=note` nodes with a dashed anchor edge.
A kind with no DOT counterpart — sequence, table — is a *WrongFormError.
func (*Rendering) DOTWith ¶
DOTWith is the DOT form written with options: laid out in the stated direction, as `rankdir` (the empty direction leaves the engine's default and writes no `rankdir`), filled from the stated palette by keyword family (the empty palette draws in black and white), and with the nodes a positioned drawing leaves unplaced undrawn or set in a strip below it; left undrawn, the control nodes a migration made up are elided (withoutStandIns). The layout is the same whatever the palette: it changes fills and borders alone.
func (*Rendering) DataWith ¶ added in v0.11.0
DataWith is the rendering in machine-consumable form with each node's ports filtered for the display options ask, and the optional notation elements they add shown.
func (*Rendering) EmptyReason ¶
EmptyReason says why a rendering shows nothing: a view exposing nothing, one whose filter rejects or whose expose does not reach any element, or one whose exposed elements this kind of rendering cannot show, which the notices then account for one by one.
func (*Rendering) Fills ¶
Fills is the fill each node takes under the palette, by node ID, as the DOT, Mermaid, PlantUML and D2 forms fill it; a node left black and white, and every node under no palette, is absent.
func (*Rendering) Markdown ¶
Markdown is the machine-readable form of a tabular rendering: a GitHub-flavored Markdown table, which is what a table or matrix is read as where the models are — in documentation and in an editor — since Mermaid has no table grammar. What the rendering could not represent is written as Markdown comments, so no notice is lost.
func (*Rendering) MarkdownCells ¶
MarkdownCells is Markdown with the caller's cell escaping, for a host whose Markdown dialect escapes more than a pipe and a newline.
func (*Rendering) Mermaid ¶
Mermaid is the default machine-readable form of a rendering: a Mermaid diagram renders where the models are read — in Markdown documentation, in the repository's own docs, and in the editors that host the language server — without a Graphviz installation, and it has a state-diagram grammar the state rendering maps onto directly. Graphviz DOT, written by DOT, is the alternative for Graphviz toolchains and for renderings that will carry exact positions; PlantUML, written by PlantUML, for PlantUML toolchains.
A graph-shaped rendering is a `flowchart`; a state rendering is a `stateDiagram-v2` and a sequence rendering a `sequenceDiagram`. What the rendering could not represent is written as comments, so no notice is lost in the machine-readable form either.
func (*Rendering) MermaidWith ¶
MermaidWith is the Mermaid form written with options. It is drawn in the stated direction: a flowchart flows that way, and a state diagram states it as a `direction` statement. The empty direction keeps each kind's default, and a kind no direction applies to ignores it. A palette fills nodes by keyword family, and a Cameo style draws its representable colours. An interconnection or mixed rendering draws the ports its selected display returns. A rendering positioned by Layout draws the nodes the DOT form draws: the placed ones, and the unplaced ones too under UnplacedStrip.
func (*Rendering) PlantUML ¶
PlantUML is the PlantUML form of a rendering: a class diagram of a tree, a nested rectangle diagram of an interconnection, a state diagram of a state or action rendering, and a sequence diagram of a sequence, in the Standard B&W style with its rules written into the file. What the rendering could not represent is written as `'` comments, so no notice is lost.
func (*Rendering) PlantUMLWith ¶
PlantUMLWith is the PlantUML form written with options: drawn in the stated direction (PlantUML draws top to bottom or left to right, so a reversed direction takes its nearest and is noted as not represented; the empty direction leaves PlantUML's default) and filled from the stated palette by keyword family, as the DOT form is. A rendering some Layout positions draws the nodes the DOT form draws: the placed ones, and the unplaced ones too under UnplacedStrip. Placement itself is written as comments, PlantUML having no absolute positions; for pinned positions use the DOT form.
func (*Rendering) Positioned ¶ added in v0.9.2
Positioned reports whether a Layout or Route places some node of a graph-shaped rendering, or a Picture is drawn on it at stated bounds, so the DOT form draws it where the diagram states.
func (*Rendering) SVGWith ¶ added in v0.11.0
SVGWith is the rendering as an SVG drawing, animated replaying the run with SMIL; the base attributes stay the complete, final picture for a viewer without SMIL.
func (*Rendering) TSV ¶ added in v0.10.0
TSV is CSV with a tab between fields, a field holding a tab, a quote or a line break quoted as CSV quotes it, so encoding/csv reads it back.
func (*Rendering) Text ¶
Text is the human-readable form of a rendering, written to no particular width. It is ASCII throughout, so it reads the same on any terminal; a positioned node ends in `at (x, y)` and, when sized, `size W×H`.
func (*Rendering) TextWidth ¶
TextWidth is the human-readable form of a rendering: a header saying what was rendered and how, the nodes as an indented tree, the edges beneath it, and what the rendering could not represent. It is what the REPL prints. A table's tabular columns are written to fit width, wrapping their cells; WidthUnbounded writes each column as wide as its widest cell.
func (*Rendering) Write ¶
Write is the rendering in form, with the default options: no particular width, each kind's direction, black and white.
func (*Rendering) WriteWith ¶
WriteWith is the rendering in form, written with options. A form the kind is not written in is a *WrongFormError, an unknown form names the ones there are, a palette outside the registry is an *UnknownPaletteError on every form that fills nodes, and a port display outside it an *UnknownPortsError on every form.
type RowData ¶
RowData is one row of a tabular rendering: its cells, one per column, and where the element it reports was declared.
type SelectionError ¶ added in v0.10.0
type SelectionError struct {
Kind SelectionErrorKind
Err error
}
SelectionError carries the status class and unchanged message of a failed view selection or rendering.
func (*SelectionError) Error ¶ added in v0.10.0
func (e *SelectionError) Error() string
func (*SelectionError) Unwrap ¶ added in v0.10.0
func (e *SelectionError) Unwrap() error
type SelectionErrorKind ¶ added in v0.10.0
type SelectionErrorKind uint8
SelectionErrorKind classifies why a requested view could not be rendered.
const ( SelectionInvalid SelectionErrorKind = iota SelectionNotFound )
type Shown ¶ added in v0.11.0
Shown is the set of optional notation elements a rendering draws. A nil set is the default, DefaultShown; an empty set draws none of them.
func AllShown ¶ added in v0.11.0
func AllShown() Shown
AllShown is every optional element, what "all" names: the full notation.
func ParseShown ¶ added in v0.11.0
ParseShown reads a comma-separated list of element names, or "all", into the set to show: nil for an empty list. A name none has is an *UnknownElementError naming the elements there are.
func ShownOf ¶ added in v0.11.0
ShownOf is the set to show the element names, or "all", name: nil for none. A name none has is an *UnknownElementError naming the elements there are.
func (Shown) Has ¶ added in v0.11.0
Has reports whether the set shows element, reading a nil set as the default.
func (Shown) Names ¶ added in v0.11.0
Names lists the shown elements in documentation order; empty for none.
type Site ¶ added in v0.10.0
Site is where a rendered element was declared, the values a link template fills.
type SourceText ¶
SourceText answers the notation a span of a document was written in, so that a label a rendering takes verbatim — a transition guard, a trigger expression — reads as it was written. It may be nil, and returns "" for a document it does not hold, in which case such a label is described structurally instead.
type Span ¶ added in v0.10.0
type Span struct {
State string
// Origin is where the one state shown by the span was declared.
Origin Origin
From, To float64
Triggers []string
Through []string
Open bool
}
Span is a state's occupancy of a lane over clock time.
type StateLocator ¶
type StateLocator struct {
// contains filtered or unexported fields
}
StateLocator finds the nodes and edges of a rendering that draw the vertices and transitions of a lowered state machine.
func LocateStates ¶
func LocateStates(rendering *Rendering, drawn, machine *symbols.Symbol, graph *lower.StateGraph) (*StateLocator, error)
LocateStates matches graph, lowered from machine's declaration, to the root of rendering drawing drawn: the same declaration as the rendering's documents have it.
func (*StateLocator) EntryTransition ¶
func (l *StateLocator) EntryTransition(decl, owner, target ast.Node) (int, bool)
EntryTransition is the edge position of the entry transition decl written in owner's body (nil for the machine's own) to target; false when none draws it.
func (*StateLocator) Node ¶
func (l *StateLocator) Node(vertex ast.Node) (string, bool)
Node is the ID of the node drawing vertex — a state, region or pseudostate of the graph — and false for one the rendering does not draw.
func (*StateLocator) Root ¶
func (l *StateLocator) Root() string
Root is the ID of the node drawing the machine itself.
func (*StateLocator) Start ¶
func (l *StateLocator) Start(owner ast.Node) (string, bool)
Start is the ID of the start marker of the body owner owns — a state, a region, or nil for the machine's own body — and false when none is drawn.
func (*StateLocator) Transition ¶
func (l *StateLocator) Transition(decl, source, target ast.Node) (int, bool)
Transition is the edge position of decl from source to target; false when none draws it.
type Style ¶ added in v0.9.2
Style is how a node or edge is drawn, from the DiagramLayout::Style annotating it: colours as "#RRGGBB" and a font face, size in points and weight. Each field is optional; the empty value leaves it to the drawing style.
type UnknownCompartmentsError ¶ added in v0.11.0
type UnknownCompartmentsError struct {
Name string
}
UnknownCompartmentsError reports a folding that is none of the choices.
func (*UnknownCompartmentsError) Error ¶ added in v0.11.0
func (e *UnknownCompartmentsError) Error() string
func (*UnknownCompartmentsError) Unwrap ¶ added in v0.11.0
func (e *UnknownCompartmentsError) Unwrap() error
type UnknownDrawingStyleError ¶ added in v0.9.2
type UnknownDrawingStyleError struct {
Name string
}
UnknownDrawingStyleError is a style asked for by a name no style has; it names the styles there are.
func (*UnknownDrawingStyleError) Error ¶ added in v0.9.2
func (e *UnknownDrawingStyleError) Error() string
func (*UnknownDrawingStyleError) Unwrap ¶ added in v0.9.2
func (e *UnknownDrawingStyleError) Unwrap() error
type UnknownElementError ¶ added in v0.11.0
type UnknownElementError struct {
Name string
}
UnknownElementError reports an element name no optional element has.
func (*UnknownElementError) Error ¶ added in v0.11.0
func (e *UnknownElementError) Error() string
func (*UnknownElementError) Unwrap ¶ added in v0.11.0
func (e *UnknownElementError) Unwrap() error
type UnknownLinesError ¶ added in v0.11.0
type UnknownLinesError struct {
Name string
}
UnknownLinesError is a routing asked for by a name none has; it names the routings there are.
func (*UnknownLinesError) Error ¶ added in v0.11.0
func (e *UnknownLinesError) Error() string
func (*UnknownLinesError) Unwrap ¶ added in v0.11.0
func (e *UnknownLinesError) Unwrap() error
type UnknownPaletteError ¶
type UnknownPaletteError struct {
Name string
}
UnknownPaletteError is a palette asked for by a name no palette has; it names the palettes there are, so no surface refuses one without saying which.
func (*UnknownPaletteError) Error ¶
func (e *UnknownPaletteError) Error() string
func (*UnknownPaletteError) Unwrap ¶
func (e *UnknownPaletteError) Unwrap() error
type UnknownPortsError ¶ added in v0.10.0
type UnknownPortsError struct {
Name string
}
UnknownPortsError is a port display asked for by a name none has; it names the displays there are.
func (*UnknownPortsError) Error ¶ added in v0.10.0
func (e *UnknownPortsError) Error() string
func (*UnknownPortsError) Unwrap ¶ added in v0.10.0
func (e *UnknownPortsError) Unwrap() error
type UnknownUnplacedError ¶
type UnknownUnplacedError struct {
Name string
}
UnknownUnplacedError is a placement asked for by a name none has; it names the placements there are, so no surface refuses one without saying which.
func (*UnknownUnplacedError) Error ¶
func (e *UnknownUnplacedError) Error() string
func (*UnknownUnplacedError) Unwrap ¶
func (e *UnknownUnplacedError) Unwrap() error
type Unplaced ¶
type Unplaced string
Unplaced is what the DOT form does with the nodes a positioned drawing leaves unplaced: those with no Layout, no route meeting them and, for a cluster, no placed member. The empty Unplaced is UnplacedOmit.
const ( // UnplacedOmit leaves them undrawn: the drawing shows what the Layouts // place, and nothing lands on a placed box. UnplacedOmit Unplaced = "omit" // UnplacedStrip draws them in rows in a strip below the drawing, clear of // the canvas, every placed box and every route. UnplacedStrip Unplaced = "strip" )
func ParseUnplaced ¶
ParseUnplaced reports the placement name names, and whether it names one. The empty name is no placement: the default is asked for by stating none.
func UnplacedChoices ¶
func UnplacedChoices() []Unplaced
UnplacedChoices are the placements unplaced nodes can be asked for, in the order they are offered.
type UnsupportedKindError ¶
type UnsupportedKindError struct {
// Kind is the rendering kind asked for.
Kind Kind
// View is the view stating it, by qualified name.
View string
// Stated is what the model says the kind through — a rendering member, or
// the standard view definition the view specializes.
Stated string
// Remedy is what to do instead, empty when there is nothing to suggest.
Remedy string
}
UnsupportedKindError is a view stating a rendering kind that is recognized but not produced. It names both the kind and the view, and never falls back to another kind.
func (*UnsupportedKindError) Error ¶
func (e *UnsupportedKindError) Error() string
func (*UnsupportedKindError) Unwrap ¶
func (e *UnsupportedKindError) Unwrap() error
type Verdict ¶ added in v0.10.0
type Verdict struct {
// Case is the verification case, by qualified name.
Case string
// Kind is pass, fail, inconclusive or error.
Kind string
// Detail is why a run was inconclusive or failed to run, "" otherwise.
Detail string
}
Verdict is the outcome of one verification case run on a requirement.
type Verdicts ¶ added in v0.10.0
Verdicts answers the verdicts of the verification cases verifying a requirement, in a stable order; none for a requirement nothing verifies.
type WrongFormError ¶
type WrongFormError struct {
// Form is the form asked for, Kind the rendering's kind, and View the view
// rendered, by qualified name.
Form Form
Kind Kind
View string
// contains filtered or unexported fields
}
WrongFormError is a form asked for that does not fit the rendering's kind: a Mermaid diagram of a table, a Markdown table of a diagram, or DOT of a sequence. It names the forms the kind is written in instead, and never writes another form silently.
func (*WrongFormError) Error ¶
func (e *WrongFormError) Error() string
func (*WrongFormError) Unwrap ¶
func (e *WrongFormError) Unwrap() error
Source Files
¶
- behavior.go
- case.go
- clone.go
- compartment_mode.go
- compartments.go
- d2.go
- data.go
- default_kind.go
- delimited.go
- direction.go
- dot.go
- dot_boundary.go
- dot_metrics.go
- dot_ports.go
- edge_labels.go
- empty.go
- form.go
- general.go
- geometry.go
- interconnection.go
- label.go
- lines.go
- links.go
- locate.go
- markdown.go
- matrix.go
- mermaid.go
- mixed.go
- narrow.go
- notation.go
- origin.go
- palette.go
- picture.go
- pilot_style.go
- place.go
- placement.go
- plantuml.go
- ports.go
- pseudo.go
- related.go
- resolve.go
- run_svg.go
- run_timeline.go
- sequence.go
- shown.go
- standin.go
- style.go
- table.go
- text.go
- tree.go
- tree_edges.go
- unplaced.go
- verdict.go
- view.go
- walk.go