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 ReadsBody(index *symbols.Index, model *semantics.Model, rep *symbols.Symbol) bool
- 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) Items() []ListItem
- 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) Rows() []TableRow
- 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 ListItem
- type ListStyle
- type Plan
- type QueryRef
- type Run
- func (r Run) Bound() bool
- func (r Run) Kind() RunKind
- func (r Run) Origin() symbols.Origin
- func (r Run) RefDocument() string
- func (r Run) RefElement() string
- func (r Run) RefPath() []string
- func (r Run) Style() RunStyle
- func (r Run) Target() string
- func (r Run) Text() string
- func (r Run) TextDefaulted() bool
- func (r Run) ValueFeature() string
- func (r Run) ValuePath() string
- func (r Run) ValueRoot() *symbols.Symbol
- type RunKind
- type RunStyle
- type TableRow
- 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 ReadsBody ¶ added in v0.12.0
ReadsBody reports whether a document plan reads the body of the textual representation rep: one owned, at any depth, by a document, section or paragraph.
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) Items ¶ added in v0.12.0
Items returns the static items of a list planned from a markup body; empty for a list whose items a query yields.
func (Content) Kind ¶
func (c Content) Kind() ContentKind
Kind returns the classification of the node.
func (Content) Rows ¶ added in v0.12.0
Rows returns the written-out rows of a static table, in order.
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
// Line is the 1-based line within a markup body the failure is at, or 0.
Line int
// Bodies counts the bodies a missing markup converter left unchecked when
// validation went on without it, or is 0 when planning stopped at the body.
Bodies int
Err error
}
Error is a typed document-planning failure with its source location.
func Validate ¶ added in v0.12.0
func Validate(index *symbols.Index, model *semantics.Model, resolver *resolve.Resolver, entry *symbols.Symbol) (warnings []*Error, err error)
Validate plans entry as Compile does, except that a markup body whose converter is missing is left unchecked and reported as a warning, one per language, so the rest of the document is still checked. A rendering needs every body parsed and uses Compile, which stops at such a body.
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" ErrorUnknownValueTarget ErrorKind = "unknown-value-target" ErrorInvalidValueTarget ErrorKind = "invalid-value-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" ErrorUnsupportedMarkupLanguage ErrorKind = "unsupported-markup-language" ErrorUnsupportedMarkupConstruct ErrorKind = "unsupported-markup-construct" ErrorMisplacedMarkupBody ErrorKind = "misplaced-markup-body" ErrorMarkupBodyNotParagraph ErrorKind = "markup-body-not-paragraph" ErrorMarkupToolMissing ErrorKind = "markup-tool-missing" ErrorMarkupToolFailed ErrorKind = "markup-tool-failed" ErrorMarkupHeadingLevel ErrorKind = "markup-heading-level" )
func ErrorKinds ¶ added in v0.11.0
func ErrorKinds() []ErrorKind
ErrorKinds lists every error kind, in declaration order.
type ListItem ¶ added in v0.12.0
type ListItem struct {
// contains filtered or unexported fields
}
ListItem is one static list item: its inline runs and where they were written.
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) Bound ¶ added in v0.12.0
Bound reports whether the run's text already carries its spacing to the neighbouring runs, as a run cut from a markup body does, so a backend joins it without inserting a separator.
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.
func (Run) ValueFeature ¶ added in v0.12.0
ValueFeature returns the fully-qualified name of the feature a value run reads.
type TableRow ¶ added in v0.12.0
type TableRow struct {
// contains filtered or unexported fields
}
TableRow is one written-out table row: one text cell per column and where it was written.
type TemplateKind ¶
type TemplateKind string
TemplateKind classifies one planned column run of a query-backed node.
const ( TemplateSpan TemplateKind = "span" TemplateLink TemplateKind = "link" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package markup parses the body of a KerML textual representation written in a markup language into the content blocks a document plan is built from: paragraphs and lists of inline runs, each with its byte span in the body.
|
Package markup parses the body of a KerML textual representation written in a markup language into the content blocks a document plan is built from: paragraphs and lists of inline runs, each with its byte span in the body. |
|
markuptest
Package markuptest stands in for the AsciiDoc converter in tests: a recorded converter answers each body it has a recording for, so the mapping is tested without node.
|
Package markuptest stands in for the AsciiDoc converter in tests: a recorded converter answers each body it has a recording for, so the mapping is tested without node. |