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) Anchor() string
- func (c Content) Caption() string
- func (c Content) Children() []Content
- func (c Content) Columns() []queryexec.Column
- func (c Content) Direction() view.Direction
- func (c Content) GroupBy() string
- func (c Content) Groups() []TableGroup
- func (c Content) Items() []ListItem
- func (c Content) Kind() ContentKind
- func (c Content) Name() string
- func (c Content) Origin() provenance.Origin
- func (c Content) Query() string
- func (c Content) QueryOrigin() provenance.Origin
- func (c Content) Rendering() *view.Rendering
- func (c Content) Rows() []queryexec.Row
- func (c Content) Runs() []TextRun
- func (c Content) Style() ListStyle
- func (c Content) Title() string
- type ContentKind
- 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 EvaluateSet(plans []*docplan.Plan, context queryexec.Context, options queryexec.Options, ...) ([]*Document, error)
- type Error
- type ErrorKind
- 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, or diagram.
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) Direction ¶
Direction returns the stated flow direction of a diagram, empty for the kind's default.
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) Origin ¶
func (c Content) Origin() provenance.Origin
Origin returns the source declaration behind the node.
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 ¶
func (c Content) QueryOrigin() provenance.Origin
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.
type ContentKind ¶
type ContentKind string
ContentKind classifies one evaluated content node.
const ( ContentSection ContentKind = "section" ContentParagraph ContentKind = "paragraph" ContentTable ContentKind = "table" ContentList ContentKind = "list" ContentDiagram ContentKind = "diagram" )
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 EvaluateSet ¶
func EvaluateSet( plans []*docplan.Plan, context queryexec.Context, options queryexec.Options, text view.SourceText, ) ([]*Document, 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.
func (*Document) Origin ¶
func (d *Document) Origin() provenance.Origin
Origin returns the source declaration behind the document.
type Error ¶
type Error struct {
Kind ErrorKind
Document string
Content string
Query string
Column string
Row int
Actual string
Origin provenance.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" )
type ListItem ¶
type ListItem struct {
// contains filtered or unexported fields
}
ListItem is one evaluated list item, produced from one query row.
func (ListItem) Element ¶ added in v0.5.0
Element returns the model element the item's query row selected.
func (ListItem) Origin ¶
func (i ListItem) Origin() provenance.Origin
Origin returns the query row behind the item.
type RunKind ¶
type RunKind string
RunKind classifies one text run: plain prose, an inline style, 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) Origin ¶
func (r TextRun) Origin() provenance.Origin
Origin returns the source declaration or query value behind the run.
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.