document

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 5 Imported by: ? 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 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

View Source
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.

func (Problem) Error

func (problem Problem) Error() string

type Problems

type Problems []Problem

Problems aggregates validation failures without losing their field paths.

func (Problems) Error

func (problems Problems) Error() string

type Props

type Props map[string]any

Props contains JSON-shaped semantic component input.

type Style

type Style map[string]any

Style contains JSON-shaped visual choices. Renderers interpret these values; the document domain does not contain target-specific commands.

Jump to

Keyboard shortcuts

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