docplan

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package docplan compiles native SysML v2 document definitions into immutable document plans that reference compiled query programs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindsLeft added in v0.10.0

func BindsLeft(text string) bool

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

func BindsRight(text string) bool

BindsRight reports whether a run's text binds to the run after it: it closes with an opening bracket or quote.

func IsDocumentDefinition

func IsDocumentDefinition(index *symbols.Index, model *semantics.Model, sym *symbols.Symbol) bool

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

func ReadsBody(index *symbols.Index, model *semantics.Model, rep *symbols.Symbol) bool

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

func ValidRunStyle(style RunStyle) bool

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) Origin

func (b Binding) Origin() symbols.Origin

Origin returns the source declaration behind the binding.

func (Binding) Parameter

func (b Binding) Parameter() string

Parameter returns the bound parameter name.

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) Column

func (r ColumnRun) Column() string

Column returns the projected column the run's text comes from.

func (ColumnRun) Kind

func (r ColumnRun) Kind() TemplateKind

Kind returns the classification of the column run.

func (ColumnRun) Origin

func (r ColumnRun) Origin() symbols.Origin

Origin returns the source declaration behind the column run.

func (ColumnRun) Style

func (r ColumnRun) Style() RunStyle

Style returns the fixed inline style of a span column run.

func (ColumnRun) StyleColumn

func (r ColumnRun) StyleColumn() string

StyleColumn returns the projected column supplying each row's style, empty when the style is fixed.

func (ColumnRun) TargetColumn

func (r ColumnRun) TargetColumn() string

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

func (c Content) Alt() string

Alt returns the text alternative an image states, empty for none.

func (Content) Caption

func (c Content) Caption() string

Caption returns the declared caption of a table, formula, diagram or image.

func (Content) Children

func (c Content) Children() []Content

Children returns the nested content of a section in declaration order.

func (Content) ColumnLabels added in v0.9.2

func (c Content) ColumnLabels() []string

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

func (c Content) ColumnRuns() []ColumnRun

ColumnRuns returns the planned column runs of a query-backed paragraph or list in declaration order.

func (Content) ColumnWidths added in v0.9.2

func (c Content) ColumnWidths() []int

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

func (c Content) Description() string

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

func (c Content) GroupBy() string

GroupBy returns the projected column a table groups its rows by, empty when ungrouped.

func (Content) Items added in v0.12.0

func (c Content) Items() []ListItem

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) Location added in v0.9.2

func (c Content) Location() string

Location returns the path or URL an image shows.

func (Content) Name

func (c Content) Name() string

Name returns the declared name of the node, empty when anonymous.

func (Content) Origin

func (c Content) Origin() symbols.Origin

Origin returns the source declaration behind the node.

func (Content) Query

func (c Content) Query() *QueryRef

Query returns the referenced query of a query-backed node, or nil.

func (Content) Rows added in v0.12.0

func (c Content) Rows() []TableRow

Rows returns the written-out rows of a static table, in order.

func (Content) Runs

func (c Content) Runs() []Run

Runs returns the planned inline runs of a paragraph in declaration order.

func (Content) Source

func (c Content) Source() string

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.

func (Content) Style

func (c Content) Style() ListStyle

Style returns the declared style of a list.

func (Content) Term

func (c Content) Term() string

Term returns the projected column naming each entry of a definitions node.

func (Content) Text

func (c Content) Text() string

Text returns the static text of a paragraph, empty when query-backed.

func (Content) Title

func (c Content) Title() string

Title returns the declared title of a section.

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.

func (*DiagramRef) Target

func (d *DiagramRef) Target() (*symbols.Symbol, bool)

Target returns the plain element the diagram renders, when it names one.

func (*DiagramRef) View

func (d *DiagramRef) View() (*symbols.Symbol, bool)

View returns the declared view usage the diagram renders, when it names one.

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.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying query-planning failure, if any.

type ErrorKind

type ErrorKind string

ErrorKind classifies a document-planning failure.

const (
	ErrorInvalidContext             ErrorKind = "invalid-context"
	ErrorLibraryUnavailable         ErrorKind = "library-unavailable"
	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.

func (ErrorKind) Severity added in v0.12.0

func (k ErrorKind) Severity() diag.Severity

Severity is how a check reports an error of this kind: a missing markup converter leaves bodies unchecked, a warning; every other kind is an error.

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.

func (ListItem) Origin added in v0.12.0

func (i ListItem) Origin() symbols.Origin

Origin returns where the item was written.

func (ListItem) Runs added in v0.12.0

func (i ListItem) Runs() []Run

Runs returns the item's inline runs.

type ListStyle

type ListStyle string

ListStyle is the declared rendering style of a planned list.

const (
	ListBullet ListStyle = "bullet"
	ListNumber ListStyle = "number"
)

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.

func (*Plan) Compiled

func (p *Plan) Compiled() bool

Compiled reports whether the plan was produced by Compile.

func (*Plan) Content

func (p *Plan) Content() []Content

Content returns the planned top-level content in declaration order.

func (*Plan) Name

func (p *Plan) Name() string

Name returns the fully-qualified name of the document definition.

func (*Plan) Origin

func (p *Plan) Origin() symbols.Origin

Origin returns the source declaration behind the document.

func (*Plan) Title

func (p *Plan) Title() string

Title returns the declared document title.

type QueryRef

type QueryRef struct {
	// contains filtered or unexported fields
}

QueryRef is a planned reference to a compiled query with its bindings.

func (*QueryRef) Bindings

func (q *QueryRef) Bindings() []Binding

Bindings returns the planned bindings in declaration order.

func (*QueryRef) Entry

func (q *QueryRef) Entry() string

Entry returns the fully-qualified name of the referenced query.

func (*QueryRef) Origin

func (q *QueryRef) Origin() symbols.Origin

Origin returns the source declaration behind the reference.

func (*QueryRef) Program

func (q *QueryRef) Program() *queryplan.Program

Program returns the compiled program of the referenced query.

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

func (r Run) Bound() bool

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) Kind

func (r Run) Kind() RunKind

Kind returns the classification of the run.

func (Run) Origin

func (r Run) Origin() symbols.Origin

Origin returns the source declaration behind the run.

func (Run) RefDocument

func (r Run) RefDocument() string

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

func (r Run) RefElement() string

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

func (r Run) RefPath() []string

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) Style

func (r Run) Style() RunStyle

Style returns the inline style of a span run.

func (Run) Target

func (r Run) Target() string

Target returns the destination of a link run.

func (Run) Text

func (r Run) Text() string

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

func (r Run) TextDefaulted() bool

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

func (r Run) ValueFeature() string

ValueFeature returns the fully-qualified name of the feature a value run reads.

func (Run) ValuePath added in v0.12.0

func (r Run) ValuePath() string

ValuePath returns the member path a value run reads below ValueRoot, as a span column names the feature it projects.

func (Run) ValueRoot added in v0.12.0

func (r Run) ValueRoot() *symbols.Symbol

ValueRoot returns the element a value run reads from: the root of its feature chain, else the owner of the named feature. A session holding an object of it answers with that object's current value.

type RunKind

type RunKind string

RunKind classifies one planned inline run of a paragraph.

const (
	RunSpan RunKind = "span"
	RunLink RunKind = "link"
	RunRef  RunKind = "ref"
	// RunValue reads a feature's value into the prose, as a span column does.
	RunValue RunKind = "value"
)

type RunStyle

type RunStyle string

RunStyle is the declared inline style of a span run.

const (
	StylePlain    RunStyle = "plain"
	StyleEmphasis RunStyle = "emphasis"
	StyleStrong   RunStyle = "strong"
	StyleCode     RunStyle = "code"
	// StyleMath typesets the span's text, LaTeX source, as inline mathematics.
	StyleMath RunStyle = "math"
)

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.

func (TableRow) Cells added in v0.12.0

func (r TableRow) Cells() []string

Cells returns the row's cell texts, one per column.

func (TableRow) Origin added in v0.12.0

func (r TableRow) Origin() symbols.Origin

Origin returns where the row 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"
)

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.

Jump to

Keyboard shortcuts

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