Documentation
¶
Overview ¶
Package docplan compiles native SysML v2 document definitions into immutable document plans that reference compiled query programs.
Index ¶
- func BindsLeft(text string) bool
- func BindsRight(text string) bool
- func IsDocumentDefinition(index *symbols.Index, model *semantics.Model, sym *symbols.Symbol) bool
- func QueryTarget(index *symbols.Index, model *semantics.Model, resolver *resolve.Resolver, ...) *symbols.Symbol
- func ValidRunStyle(style RunStyle) bool
- type Binding
- type BindingKind
- type BindingValue
- func (v BindingValue) Boolean() (bool, bool)
- func (v BindingValue) Element() (*symbols.Symbol, bool)
- func (v BindingValue) Integer() (int64, bool)
- func (v BindingValue) IntegerConst() (semantics.Value, bool)
- func (v BindingValue) Kind() BindingKind
- func (v BindingValue) Origin() symbols.Origin
- func (v BindingValue) Rational() (semantics.Value, bool)
- func (v BindingValue) Real() (float64, bool)
- func (v BindingValue) String() (string, bool)
- type ColumnRun
- type Content
- func (c Content) Alt() string
- func (c Content) Caption() string
- func (c Content) Children() []Content
- func (c Content) ColumnLabels() []string
- func (c Content) ColumnRuns() []ColumnRun
- func (c Content) ColumnWidths() []int
- func (c Content) Description() string
- func (c Content) Diagram() *DiagramRef
- func (c Content) GroupBy() string
- func (c Content) Kind() ContentKind
- func (c Content) Location() string
- func (c Content) Name() string
- func (c Content) Origin() symbols.Origin
- func (c Content) Query() *QueryRef
- func (c Content) Runs() []Run
- func (c Content) Source() string
- func (c Content) Style() ListStyle
- func (c Content) Term() string
- func (c Content) Text() string
- func (c Content) Title() string
- type ContentKind
- type DiagramRef
- func (d *DiagramRef) Direction() view.Direction
- func (d *DiagramRef) Kind() view.Kind
- func (d *DiagramRef) Origin() symbols.Origin
- func (d *DiagramRef) Overlay() view.Overlay
- func (d *DiagramRef) Palette() view.Palette
- func (d *DiagramRef) Ports() view.Ports
- func (d *DiagramRef) Shown() view.Shown
- func (d *DiagramRef) Stated() string
- func (d *DiagramRef) Target() (*symbols.Symbol, bool)
- func (d *DiagramRef) View() (*symbols.Symbol, bool)
- type Error
- type ErrorKind
- type ListStyle
- type Plan
- type QueryRef
- type Run
- type RunKind
- type RunStyle
- type TemplateKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindsLeft ¶ added in v0.10.0
BindsLeft reports whether a run's text binds to the run before it, so no space separates them when the runs are joined: it opens with closing punctuation, as the ")." of "(see Section 2)." does.
func BindsRight ¶ added in v0.10.0
BindsRight reports whether a run's text binds to the run after it: it closes with an opening bracket or quote.
func IsDocumentDefinition ¶
IsDocumentDefinition reports whether sym specializes DocumentQueries::Document.
func QueryTarget ¶
func QueryTarget(index *symbols.Index, model *semantics.Model, resolver *resolve.Resolver, usage *symbols.Symbol) *symbols.Symbol
QueryTarget resolves the query definition a calc usage is typed by, following redefinition lineage; nil when it is not typed by a query definition.
func ValidRunStyle ¶
ValidRunStyle reports whether a style names one of the span styles.
Types ¶
type Binding ¶
type Binding struct {
// contains filtered or unexported fields
}
Binding supplies planned values to one parameter of a referenced query.
func (Binding) Values ¶
func (b Binding) Values() []BindingValue
Values returns the planned values in declaration order.
type BindingKind ¶
type BindingKind string
BindingKind classifies one planned binding value.
const ( BindingElement BindingKind = "element" BindingString BindingKind = "string" BindingInteger BindingKind = "integer" BindingReal BindingKind = "real" // BindingRational is an exact decimal literal, `0.1`. BindingRational BindingKind = "rational" BindingBoolean BindingKind = "boolean" )
type BindingValue ¶
type BindingValue struct {
// contains filtered or unexported fields
}
BindingValue is one statically planned value for a query parameter.
func (BindingValue) Boolean ¶
func (v BindingValue) Boolean() (bool, bool)
Boolean returns the bound boolean when the value is a boolean.
func (BindingValue) Element ¶
func (v BindingValue) Element() (*symbols.Symbol, bool)
Element returns the bound model element when the value is an element.
func (BindingValue) Integer ¶
func (v BindingValue) Integer() (int64, bool)
Integer returns the bound integer when the value is an integer within int64; IntegerConst reads any integer.
func (BindingValue) IntegerConst ¶ added in v0.10.0
func (v BindingValue) IntegerConst() (semantics.Value, bool)
IntegerConst returns the bound Integer, of any size, when the value is an integer.
func (BindingValue) Kind ¶
func (v BindingValue) Kind() BindingKind
Kind returns the classification of the value.
func (BindingValue) Origin ¶
func (v BindingValue) Origin() symbols.Origin
Origin returns the source declaration behind the value.
func (BindingValue) Rational ¶ added in v0.10.0
func (v BindingValue) Rational() (semantics.Value, bool)
Rational returns the bound exact Rational when the value is a rational.
func (BindingValue) Real ¶
func (v BindingValue) Real() (float64, bool)
Real returns the bound real when the value is a real.
func (BindingValue) String ¶
func (v BindingValue) String() (string, bool)
String returns the bound text when the value is a string.
type ColumnRun ¶
type ColumnRun struct {
// contains filtered or unexported fields
}
ColumnRun maps one projected column of a query-backed paragraph or list to a styled run per result row.
func (ColumnRun) Kind ¶
func (r ColumnRun) Kind() TemplateKind
Kind returns the classification of the column run.
func (ColumnRun) StyleColumn ¶
StyleColumn returns the projected column supplying each row's style, empty when the style is fixed.
func (ColumnRun) TargetColumn ¶
TargetColumn returns the projected column supplying each row's link destination.
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
Content is one planned content node: a section, paragraph, table, list, definitions, formula, diagram, or image.
func (Content) Alt ¶ added in v0.9.2
Alt returns the text alternative an image states, empty for none.
func (Content) Caption ¶
Caption returns the declared caption of a table, formula, diagram or image.
func (Content) ColumnLabels ¶ added in v0.9.2
ColumnLabels returns the stated headings of a table's columns in projection order, one per column stated; "" heads a column by its name.
func (Content) ColumnRuns ¶
ColumnRuns returns the planned column runs of a query-backed paragraph or list in declaration order.
func (Content) ColumnWidths ¶ added in v0.9.2
ColumnWidths returns the stated widths of a table's columns in projection order, one per column stated; 0 sizes a column automatically.
func (Content) Description ¶
Description returns the projected column describing each entry of a definitions node.
func (Content) Diagram ¶
func (c Content) Diagram() *DiagramRef
Diagram returns the planned view reference of a diagram node, or nil.
func (Content) GroupBy ¶
GroupBy returns the projected column a table groups its rows by, empty when ungrouped.
func (Content) Kind ¶
func (c Content) Kind() ContentKind
Kind returns the classification of the node.
func (Content) Source ¶
Source returns the LaTeX source of a formula, or the location an image block shows: a path relative to the document's source file, or a URL.
type ContentKind ¶
type ContentKind string
ContentKind classifies one planned content node.
const ( ContentSection ContentKind = "section" ContentParagraph ContentKind = "paragraph" ContentTable ContentKind = "table" ContentList ContentKind = "list" ContentDefinitions ContentKind = "definitions" ContentFormula ContentKind = "formula" ContentDiagram ContentKind = "diagram" ContentImage ContentKind = "image" )
type DiagramRef ¶
type DiagramRef struct {
// contains filtered or unexported fields
}
DiagramRef is a planned reference to what a diagram renders: a declared view usage, or a plain element with the rendering kind the diagram states.
func (*DiagramRef) Direction ¶
func (d *DiagramRef) Direction() view.Direction
Direction returns the stated flow direction, empty for the kind's default.
func (*DiagramRef) Kind ¶
func (d *DiagramRef) Kind() view.Kind
Kind returns the resolved rendering kind.
func (*DiagramRef) Origin ¶
func (d *DiagramRef) Origin() symbols.Origin
Origin returns the source declaration behind the reference.
func (*DiagramRef) Overlay ¶ added in v0.10.0
func (d *DiagramRef) Overlay() view.Overlay
Overlay returns the stated overlay, empty for a purely structural drawing.
func (*DiagramRef) Palette ¶
func (d *DiagramRef) Palette() view.Palette
Palette returns the stated palette, empty for black and white.
func (*DiagramRef) Ports ¶ added in v0.10.0
func (d *DiagramRef) Ports() view.Ports
Ports returns the stated port display, empty for the default, minimal.
func (*DiagramRef) Shown ¶ added in v0.11.0
func (d *DiagramRef) Shown() view.Shown
Shown is the optional notation elements the diagram states to draw, nil when it states none.
func (*DiagramRef) Stated ¶
func (d *DiagramRef) Stated() string
Stated returns how the kind was decided, the way a rendering reports it.
type Error ¶
type Error struct {
Kind ErrorKind
Document string
Content string
Query string
Parameter string
Expected string
Actual string
Origin symbols.Origin
Err error
}
Error is a typed document-planning failure with its source location.
type ErrorKind ¶
type ErrorKind string
ErrorKind classifies a document-planning failure.
const ( ErrorInvalidContext ErrorKind = "invalid-context" ErrorNotDocumentDefinition ErrorKind = "not-document-definition" ErrorMissingTitle ErrorKind = "missing-title" ErrorInvalidAttribute ErrorKind = "invalid-attribute" ErrorInvalidContent ErrorKind = "invalid-content" ErrorNestedDocument ErrorKind = "nested-document" ErrorMissingText ErrorKind = "missing-text" ErrorConflictingText ErrorKind = "conflicting-text" ErrorMissingQuery ErrorKind = "missing-query" ErrorConflictingQuery ErrorKind = "conflicting-query" ErrorUnknownQuery ErrorKind = "unknown-query" ErrorQueryPlanning ErrorKind = "query-planning" ErrorInvalidStyle ErrorKind = "invalid-style" ErrorUnknownParameter ErrorKind = "unknown-parameter" ErrorDuplicateBinding ErrorKind = "duplicate-binding" ErrorMissingBinding ErrorKind = "missing-binding" ErrorUnsupportedBinding ErrorKind = "unsupported-binding" ErrorBindingType ErrorKind = "binding-type" ErrorBindingMultiplicity ErrorKind = "binding-multiplicity" ErrorMissingViewSource ErrorKind = "missing-view-source" ErrorInvalidViewSource ErrorKind = "invalid-view-source" ErrorUnknownViewSource ErrorKind = "unknown-view-source" ErrorMissingDiagramKind ErrorKind = "missing-diagram-kind" ErrorConflictingKind ErrorKind = "conflicting-diagram-kind" ErrorUnsupportedKind ErrorKind = "unsupported-diagram-kind" ErrorInvalidDirection ErrorKind = "invalid-direction" ErrorUnsupportedDirection ErrorKind = "unsupported-direction" ErrorInvalidPalette ErrorKind = "invalid-palette" ErrorUnsupportedPalette ErrorKind = "unsupported-palette" ErrorInvalidPorts ErrorKind = "invalid-ports" ErrorUnsupportedPorts ErrorKind = "unsupported-ports" ErrorInvalidShow ErrorKind = "invalid-show" ErrorInvalidOverlay ErrorKind = "invalid-overlay" ErrorUnsupportedOverlay ErrorKind = "unsupported-overlay" ErrorConflictingRuns ErrorKind = "conflicting-runs" ErrorAmbiguousRun ErrorKind = "ambiguous-run" ErrorMissingRunText ErrorKind = "missing-run-text" ErrorInvalidRunStyle ErrorKind = "invalid-run-style" ErrorMissingLinkTarget ErrorKind = "missing-link-target" ErrorMissingRefTarget ErrorKind = "missing-ref-target" ErrorUnknownRefTarget ErrorKind = "unknown-ref-target" ErrorInvalidRefTarget ErrorKind = "invalid-ref-target" ErrorAmbiguousRefTarget ErrorKind = "ambiguous-ref-target" ErrorUnknownGroupColumn ErrorKind = "unknown-group-column" ErrorInvalidColumnWidths ErrorKind = "invalid-column-widths" ErrorInvalidColumnLabels ErrorKind = "invalid-column-labels" ErrorColumnRunWithoutQuery ErrorKind = "column-run-without-query" ErrorConflictingColumnRuns ErrorKind = "conflicting-column-runs" ErrorMissingRunColumn ErrorKind = "missing-run-column" ErrorConflictingRunStyle ErrorKind = "conflicting-run-style" ErrorUnknownRunColumn ErrorKind = "unknown-run-column" ErrorMissingDefinitionColumn ErrorKind = "missing-definition-column" ErrorUnknownDefinitionColumn ErrorKind = "unknown-definition-column" ErrorMissingFormulaSource ErrorKind = "missing-formula-source" ErrorMissingImageLocation ErrorKind = "missing-image-location" )
func ErrorKinds ¶ added in v0.11.0
func ErrorKinds() []ErrorKind
ErrorKinds lists every error kind, in declaration order.
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
Plan is an immutable compiled document definition.
func Compile ¶
func Compile(index *symbols.Index, model *semantics.Model, resolver *resolve.Resolver, entry *symbols.Symbol) (*Plan, error)
Compile compiles a document definition into an immutable document plan.
type QueryRef ¶
type QueryRef struct {
// contains filtered or unexported fields
}
QueryRef is a planned reference to a compiled query with its bindings.
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run is one planned inline run: a styled span, a link, or a reference to a content block of this or another document, another document's root, or a model element outside every document.
func (Run) RefDocument ¶
RefDocument returns the fully-qualified name of the document a reference run targets, or "" when it targets the document being planned.
func (Run) RefElement ¶ added in v0.10.0
RefElement returns the fully-qualified name of the model element a reference run targets when that is neither a content block nor a document, or "" when it is one.
func (Run) RefPath ¶
RefPath returns the named content path of a reference run, from the target document's root to the referenced content block; empty when the run references another document's root.
func (Run) Text ¶
Text returns the run's text; for a reference, the resolved label when the run states none.
func (Run) TextDefaulted ¶ added in v0.10.0
TextDefaulted reports whether a reference run's text is its target's label, the run stating none.
type TemplateKind ¶
type TemplateKind string
TemplateKind classifies one planned column run of a query-backed node.
const ( TemplateSpan TemplateKind = "span" TemplateLink TemplateKind = "link" )