Documentation
¶
Overview ¶
Package document defines AutoPDF's inert, versioned document model.
A DocumentSpec is the source of truth for composition. Renderers may project it into LaTeX, HTML, or another target, but generated fragments are never written back into the domain model.
Index ¶
Constants ¶
const CurrentSchemaVersion = 1
CurrentSchemaVersion is the latest DocumentSpec wire format understood by this package.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetRef ¶
type AssetRef struct {
ID string `json:"id"`
URI string `json:"uri,omitempty"`
MediaType string `json:"mediaType,omitempty"`
Digest string `json:"digest,omitempty"`
}
AssetRef identifies an asset without coupling the domain to a filesystem or transport. A collector resolves URI at the effect boundary.
type Component ¶
type Component struct {
ID string `json:"id"`
Kind string `json:"kind"`
Variant string `json:"variant"`
Props Props `json:"props,omitempty"`
Style Style `json:"style,omitempty"`
Assets []AssetRef `json:"assets,omitempty"`
Children []Component `json:"children,omitempty"`
}
Component is one ordered node in a document tree.
type CompositionMode ¶
type CompositionMode string
CompositionMode describes layout coupling. Component definitions choose the mode; users only choose semantic kinds and variants.
const ( // Flow participates in surrounding pagination and is normally projected as // a LaTeX \input fragment. Flow CompositionMode = "flow" // Section has explicit page boundaries and may be projected as a LaTeX // \include unit for focused previews. Section CompositionMode = "section" // Artifact is independently renderable and may be cached or embedded. Artifact CompositionMode = "artifact" )
func (CompositionMode) Valid ¶
func (mode CompositionMode) Valid() bool
Valid reports whether mode is a supported composition mode.
type DocumentSpec ¶
type DocumentSpec struct {
SchemaVersion int `json:"schemaVersion"`
ID string `json:"id,omitempty"`
Theme string `json:"theme,omitempty"`
Blocks []Component `json:"blocks"`
}
DocumentSpec is the versioned, renderer-independent source document.
func Decode ¶
func Decode(data []byte) (DocumentSpec, error)
Decode parses one strict JSON document and validates its domain invariants.
func (DocumentSpec) Clone ¶
func (spec DocumentSpec) Clone() (DocumentSpec, error)
Clone returns a deeply owned copy through the canonical JSON representation.
func (DocumentSpec) Problems ¶
func (spec DocumentSpec) Problems() Problems
Problems returns every structural validation failure in stable tree order.
type Problem ¶
type Problem struct {
ComponentID string `json:"componentId,omitempty"`
Path string `json:"path"`
Code string `json:"code"`
Message string `json:"message"`
}
Problem is a field-addressable validation failure suitable for API and web editor responses.