docir

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 8 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 docir evaluates compiled document plans into an immutable, backend-agnostic document tree with provenance on every node.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnchorFor

func AnchorFor(path []string) string

AnchorFor derives a content node's stable anchor from its named path: segments joined by "-", with every byte outside [A-Za-z0-9_] encoded as "." and two uppercase hex digits, so distinct paths never collide.

Types

type Content

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

Content is one evaluated content node: a section, paragraph, table, list, definitions block, or diagram.

func (Content) Anchor

func (c Content) Anchor() string

Anchor returns the node's stable identifier when a reference run targets it, empty otherwise.

func (Content) Caption

func (c Content) Caption() string

Caption returns the caption of a table or diagram.

func (Content) Children

func (c Content) Children() []Content

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

func (Content) Columns

func (c Content) Columns() []queryexec.Column

Columns returns the ordered projected columns of a table, preserved even when the query returned no rows.

func (Content) Definitions added in v0.6.0

func (c Content) Definitions() []Definition

Definitions returns the ordered entries of a definitions block.

func (Content) Direction

func (c Content) Direction() view.Direction

Direction returns the stated flow direction of a diagram, empty for the kind's default.

func (Content) GroupBy

func (c Content) GroupBy() string

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

func (c Content) Items() []ListItem

Items returns the ordered items of a list.

func (Content) Kind

func (c Content) Kind() ContentKind

Kind returns the classification of the node.

func (Content) Name

func (c Content) Name() string

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

func (Content) Options added in v0.8.0

func (c Content) Options() view.Options

Options returns what a diagram's rendering is written with: its stated direction and palette.

func (Content) Origin

func (c Content) Origin() provenance.Origin

Origin returns the source declaration behind the node.

func (Content) Palette added in v0.8.0

func (c Content) Palette() view.Palette

Palette returns the stated palette of a diagram, empty for black and white.

func (Content) Query

func (c Content) Query() string

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

func (c Content) Rendering() *view.Rendering

Rendering returns a copy of the resolved view content of a diagram, nil for every other kind.

func (Content) Rows

func (c Content) Rows() []queryexec.Row

Rows returns the ordered rows of a table with their typed cells.

func (Content) Runs

func (c Content) Runs() []TextRun

Runs returns the text runs of a paragraph in row and column order.

func (Content) Style

func (c Content) Style() ListStyle

Style returns the style of a list.

func (Content) Title

func (c Content) Title() string

Title returns the title of a section.

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"
	ContentDiagram     ContentKind = "diagram"
)

type Definition added in v0.6.0

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

Definition is one evaluated definitions entry, produced from one query row.

func (Definition) Description added in v0.6.0

func (d Definition) Description() []TextRun

Description returns the runs describing the entry, one per value of the description column.

func (Definition) Element added in v0.6.0

func (d Definition) Element() queryexec.Value

Element returns the model element the entry's query row selected.

func (Definition) Origin added in v0.6.0

func (d Definition) Origin() provenance.Origin

Origin returns the query row behind the entry.

func (Definition) Term added in v0.6.0

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

func (d *Document) Content() []Content

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

func (*Document) Name

func (d *Document) Name() string

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

func (*Document) Origin

func (d *Document) Origin() provenance.Origin

Origin returns the source declaration behind the document.

func (*Document) Title

func (d *Document) Title() string

Title returns the document title.

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.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying execution or rendering failure, if any.

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"
	ErrorUnknownDefinitionColumn ErrorKind = "unknown-definition-column"
)

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

func (i ListItem) Element() queryexec.Value

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.

func (ListItem) Runs

func (i ListItem) Runs() []TextRun

Runs returns the item's text runs in column order.

type ListStyle

type ListStyle string

ListStyle is the rendering style of an evaluated list.

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

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.

const (
	RunPlain    RunKind = "plain"
	RunEmphasis RunKind = "emphasis"
	RunStrong   RunKind = "strong"
	RunCode     RunKind = "code"
	RunLink     RunKind = "link"
	RunRef      RunKind = "ref"
)

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

func (r TextRun) Kind() RunKind

Kind returns the classification of the run; the zero value is plain.

func (TextRun) Origin

func (r TextRun) Origin() provenance.Origin

Origin returns the source declaration or query value behind the run.

func (TextRun) Target

func (r TextRun) Target() string

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

func (r TextRun) TargetDocument() string

TargetDocument returns the fully-qualified name of the document a reference run targets, or "" when it targets its own document.

func (TextRun) Text

func (r TextRun) Text() string

Text returns the run's text.

Jump to

Keyboard shortcuts

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