Macaw.Frame.Document.Schema.Spec (macaw_frame v0.1.0)

Copy Markdown View Source

The key spec builder the schema's tables are written with (spec/02 §1.2–§1.5).

Macaw.Frame.Document.Schema.Design, .Frame and .Layer write their tables with spec/4; Macaw.Frame.Document.Schema reads them once, at compile time, so none of them may depend on the schema module itself. A key spec is a map: the key, its type (§1.4), its facet (§1.3), its default, whether it is required, and its merge rule (§1.5).

iex> Macaw.Frame.Document.Schema.Spec.spec(:gap, :number, :geometry, default: 0)
%{key: :gap, type: :number, facet: :geometry, default: 0, required: false, merge: :override, range: nil}

Summary

Types

t()

One key of a node kind.

Functions

Every member of every enumeration inside a type, nested types included.

A key spec; default:, required: and merge: (:override when not given).

The type a styles entry takes (§2.6): a style node, a reference to another style, or a list of references and nodes stacked left to right. A field or generator entry is a site's alone.

The type a style site takes (§3.6): a reference, an inline node, a field binding whose value per datum names a style, a generator call whose result is a style, or a list of those, laid left to right.

Types

t()

@type t() :: %{
  key: atom() | String.t(),
  type: atom() | tuple(),
  facet: :binding | :channel | :geometry | :style | :content,
  default: term(),
  required: boolean(),
  merge: :concat | :union | :deep | :override | {:type, :style},
  range: {number(), number(), number()} | nil
}

One key of a node kind.

Functions

enum_members(arg1)

@spec enum_members(atom() | tuple()) :: [atom()]

Every member of every enumeration inside a type, nested types included.

spec(key, type, facet, opts \\ [])

@spec spec(atom() | String.t(), atom() | tuple(), atom(), keyword()) :: t()

A key spec; default:, required: and merge: (:override when not given).

style_entry()

@spec style_entry() :: tuple()

The type a styles entry takes (§2.6): a style node, a reference to another style, or a list of references and nodes stacked left to right. A field or generator entry is a site's alone.

style_stack()

@spec style_stack() :: tuple()

The type a style site takes (§3.6): a reference, an inline node, a field binding whose value per datum names a style, a generator call whose result is a style, or a list of those, laid left to right.

iex> {:one_of, alternatives} = Macaw.Frame.Document.Schema.Spec.style_stack()
iex> {:ref, :style} in alternatives
true