Documentation
¶
Overview ¶
Package docir evaluates compiled document plans into an immutable, backend-agnostic document tree with provenance on every node.
Index ¶
- func AnchorFor(path []string) string
- type Content
- func (c Content) Alt() string
- func (c Content) Anchor() string
- func (c Content) Caption() string
- func (c Content) Children() []Content
- func (c Content) Columns() []queryexec.Column
- func (c Content) Definitions() []Definition
- func (c Content) Direction() view.Direction
- func (c Content) File() string
- func (c Content) GroupBy() string
- func (c Content) Groups() []TableGroup
- func (c Content) Items() []ListItem
- func (c Content) Kind() ContentKind
- func (c Content) Location() string
- func (c Content) Name() string
- func (c Content) Options() view.Options
- func (c Content) Origin() symbols.Origin
- func (c Content) Palette() view.Palette
- func (c Content) Ports() view.Ports
- func (c Content) Query() string
- func (c Content) QueryOrigin() symbols.Origin
- func (c Content) Rendering() *view.Rendering
- func (c Content) Rows() []queryexec.Row
- func (c Content) Runs() []TextRun
- func (c Content) Sites() view.Sites
- func (c Content) Source() string
- func (c Content) Style() ListStyle
- func (c Content) Title() string
- type ContentKind
- type Definition
- type Document
- func Evaluate(plan *docplan.Plan, context queryexec.Context, options queryexec.Options, ...) (*Document, error)
- func EvaluateLinked(plan *docplan.Plan, siblings []*docplan.Plan, context queryexec.Context, ...) (*Document, error)
- func Unrendered(name, title string, err error, siblings []*docplan.Plan) *Document
- type Error
- type ErrorKind
- type Evaluated
- type ListItem
- type ListStyle
- type RunKind
- type TableGroup
- type TextRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
Content is one evaluated content node: a section, paragraph, table, list, definitions block, 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) Anchor ¶
Anchor returns the node's stable identifier when a reference run targets it, empty otherwise.
func (Content) Columns ¶
Columns returns the ordered projected columns of a table, preserved even when the query returned no rows.
func (Content) Definitions ¶
func (c Content) Definitions() []Definition
Definitions returns the ordered entries of a definitions block.
func (Content) Direction ¶
Direction returns the stated flow direction of a diagram, empty for the kind's default.
func (Content) File ¶ added in v0.9.2
File returns the file on disk an image block was declared in, which its relative location is stated against; "" when it was declared in none.
func (Content) GroupBy ¶
GroupBy returns the projected column a table groups its rows by, empty when ungrouped.
func (Content) Groups ¶
func (c Content) Groups() []TableGroup
Groups returns the ordered row groups of a grouped table.
func (Content) Kind ¶
func (c Content) Kind() ContentKind
Kind returns the classification of the node.
func (Content) Options ¶
Options returns what a diagram's rendering is written with: its stated direction and palette.
func (Content) Palette ¶
Palette returns the stated palette of a diagram, empty for black and white.
func (Content) Ports ¶ added in v0.10.0
Ports returns the stated port display of a diagram, empty for the default, minimal.
func (Content) Query ¶
Query returns the fully-qualified name of the query behind a query-backed node, empty for sections and static paragraphs.
func (Content) QueryOrigin ¶
QueryOrigin returns the declaration of the query behind a query-backed node.
func (Content) Rendering ¶
Rendering returns a copy of the resolved view content of a diagram, nil for every other kind.
func (Content) Sites ¶ added in v0.10.0
Sites returns the source locations diagrams in this content link to.
type ContentKind ¶
type ContentKind string
ContentKind classifies one evaluated 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 Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
Definition is one evaluated definitions entry, produced from one query row.
func (Definition) Description ¶
func (d Definition) Description() []TextRun
Description returns the runs describing the entry, one per value of the description column.
func (Definition) Element ¶
func (d Definition) Element() queryexec.Value
Element returns the model element the entry's query row selected.
func (Definition) Origin ¶
func (d Definition) Origin() symbols.Origin
Origin returns the query row behind the entry.
func (Definition) Term ¶
func (d Definition) Term() []TextRun
Term returns the runs naming the entry, one per value of the term column.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is an immutable evaluated document.
func Evaluate ¶
func Evaluate( plan *docplan.Plan, context queryexec.Context, options queryexec.Options, text view.SourceText, ) (*Document, error)
Evaluate evaluates a compiled document plan into an immutable document, executing every referenced query through the query execution engine. text supplies notation labels to diagram renderings and may be nil.
func EvaluateLinked ¶
func EvaluateLinked( plan *docplan.Plan, siblings []*docplan.Plan, context queryexec.Context, options queryexec.Options, text view.SourceText, ) (*Document, error)
EvaluateLinked evaluates one plan like Evaluate while also emitting the stable anchors the sibling documents' plans reference into it, so a document rendered on its own carries the anchors incoming cross-document links expect once the files share a directory.
func Unrendered ¶ added in v0.9.2
Unrendered is the document a set writes in place of the one named name, titled title, that could not be rendered: a paragraph stating why, then one carrying each anchor the siblings' plans link into it by, so every link into the document lands on the reason rather than on nothing.
func (*Document) ElementName ¶ added in v0.9.2
ElementName is the name an element value of the document is displayed by: its effective name in the model the document was evaluated in, else its qualified name.
type Error ¶
type Error struct {
Kind ErrorKind
Document string
Content string
Query string
Column string
Row int
Actual string
Origin symbols.Origin
Err error
}
Error is a typed document-evaluation failure with its source location.
type ErrorKind ¶
type ErrorKind string
ErrorKind classifies a document-evaluation failure.
const ( ErrorInvalidContext ErrorKind = "invalid-context" ErrorInvalidPlan ErrorKind = "invalid-plan" ErrorQueryExecution ErrorKind = "query-execution" ErrorViewRendering ErrorKind = "view-rendering" ErrorUnknownGroup ErrorKind = "unknown-group-column" ErrorUnknownRunColumn ErrorKind = "unknown-run-column" ErrorInvalidRunStyle ErrorKind = "invalid-run-style" ErrorInvalidRunTarget ErrorKind = "invalid-run-target" ErrorBlankMath ErrorKind = "blank-math" ErrorUnknownDefinitionColumn ErrorKind = "unknown-definition-column" ErrorMissingImageLocation ErrorKind = "missing-image-location" // ErrorValueEvaluation: a value run's feature could not be read. ErrorValueEvaluation ErrorKind = "value-evaluation" // ErrorEmptyValue: a value run's feature has no value to render. ErrorEmptyValue ErrorKind = "empty-value" )
type Evaluated ¶ added in v0.9.2
Evaluated is the outcome of evaluating one plan of a set: the document, or under Err the error that kept the plan named Name from evaluating.
func EvaluateSet ¶
func EvaluateSet( plans []*docplan.Plan, context queryexec.Context, options queryexec.Options, text view.SourceText, ) ([]Evaluated, error)
EvaluateSet evaluates a set of compiled document plans together, so a content block one document references from another carries its anchor in the rendered target document. Each plan evaluates on its own: one that fails leaves the others' documents whole and is reported in its outcome. A plan that is not compiled fails the set.
type ListItem ¶
type ListItem struct {
// contains filtered or unexported fields
}
ListItem is one evaluated list item, produced from one query row.
type RunKind ¶
type RunKind string
RunKind classifies one text run: plain prose, an inline style, inline mathematics, a link to an external destination, or a reference to another content node.
type TableGroup ¶
type TableGroup struct {
// contains filtered or unexported fields
}
TableGroup is one group of a grouped table's rows sharing a group-column value, in order of first appearance.
func (TableGroup) Key ¶
func (g TableGroup) Key() string
Key returns the shared group-column text of the group's rows.
func (TableGroup) Rows ¶
func (g TableGroup) Rows() []queryexec.Row
Rows returns the group's rows in result order.
type TextRun ¶
type TextRun struct {
// contains filtered or unexported fields
}
TextRun is one piece of paragraph or list-item text with its provenance: static text carries its declaration, query-backed text its query value.
func (TextRun) Bound ¶ added in v0.12.0
Bound reports whether the run's text already carries its spacing to the neighbouring runs, so a backend joins it to them without a separator.
func (TextRun) Target ¶
Target returns a link run's destination, or a reference run's anchor — the stable identifier of the referenced content node. A reference to another document's root has no anchor.
func (TextRun) TargetDocument ¶
TargetDocument returns the fully-qualified name of the document a reference run targets, or "" when it targets its own document.
func (TextRun) TargetElement ¶ added in v0.10.0
TargetElement returns the fully-qualified name of the model element a reference run targets when that is neither a content block nor a document — a reference no document gives an anchor — or "" when it is one.
func (TextRun) TextDefaulted ¶ added in v0.10.0
TextDefaulted reports whether a reference run's text is its target's label, the run stating none: a renderer numbering its sections or figures may label the target by its number instead.