Documentation
¶
Overview ¶
Package doc provides the language-neutral document model used by the Glippy formatter. The Phase 0 surface is intentionally small while the renderer's bounded behavior is proven.
Index ¶
- type Arena
- func (a *Arena) BreakParent() ID
- func (a *Arena) Concat(parts ...ID) ID
- func (a *Arena) Empty() ID
- func (a *Arena) Group(body ID) ID
- func (a *Arena) GroupWithIndependentTail(body, lookahead, tail ID) ID
- func (a *Arena) HardLine() ID
- func (a *Arena) IfBreak(broken, flat ID) ID
- func (a *Arena) Indent(body ID) ID
- func (a *Arena) Line() ID
- func (a *Arena) LineSuffix(body ID) ID
- func (a *Arena) LineSuffixBoundary() ID
- func (a *Arena) Render(root ID, options Options) (string, error)
- func (a *Arena) RenderWithMarkers(root ID, options Options) (RenderResult, error)
- func (a *Arena) SoftLine() ID
- func (a *Arena) SourceMarker(mark SourceMark) ID
- func (a *Arena) Text(value string) ID
- func (a *Arena) Verbatim(value string) ID
- type ID
- type Options
- type RenderResult
- type RenderedMarker
- type SourceMark
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arena ¶
type Arena struct {
// contains filtered or unexported fields
}
Arena owns document nodes. Nodes never change after they are appended, so a completed document may be rendered concurrently while the Arena is no longer being built.
func NewArena ¶
func NewArena() *Arena
NewArena constructs an Arena containing the shared empty document.
func NewArenaWithCapacity ¶
NewArenaWithCapacity constructs an Arena with a caller-supplied node capacity hint. The hint changes allocation only; it does not limit growth.
func (*Arena) BreakParent ¶
BreakParent prevents an enclosing group from selecting its flat form.
func (*Arena) GroupWithIndependentTail ¶
GroupWithIndependentTail selects body layout using only body and lookahead, then renders tail with an independent layout decision. A broken body gives tail one continuation indentation level.
func (*Arena) HardLine ¶
HardLine always emits a newline and prevents an enclosing group from flattening across it.
func (*Arena) LineSuffix ¶
LineSuffix defers body until immediately before the next rendered line boundary or the end of the document.
func (*Arena) LineSuffixBoundary ¶
LineSuffixBoundary emits a line boundary when a suffix is pending.
func (*Arena) Render ¶
Render renders root without backtracking. Fit simulation is capped by the configured command budget; exhausting the budget chooses a conservative broken layout.
func (*Arena) RenderWithMarkers ¶
func (a *Arena) RenderWithMarkers(root ID, options Options) (RenderResult, error)
RenderWithMarkers renders root and returns physical source-to-output marker mappings. Output offsets are bytes.
func (*Arena) SourceMarker ¶
func (a *Arena) SourceMarker(mark SourceMark) ID
SourceMarker records the current rendered byte offset without emitting text.
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID identifies an immutable document node owned by one Arena.
type RenderResult ¶
type RenderResult struct {
Text string
Markers []RenderedMarker
}
RenderResult contains rendered text and ordered source marker mappings.
type RenderedMarker ¶
type RenderedMarker struct {
Source SourceMark
OutputOffset int
}
RenderedMarker maps a source marker to a byte offset in rendered output.
type SourceMark ¶
type SourceMark struct {
Offset int
}
SourceMark identifies a physical source offset carried through rendering.