DocShell.Presentation.GraphProjector behaviour (DocShell v0.1.0)

Copy Markdown View Source

Port implemented by graph-backed hosts to produce DocShell presentation data.

A host projector reads its own store and answers with the same DocShell.Presentation.Source.presentation/0 the built-in generator produces. project/2 checks the answer before returning it, because a projector lives in another repository: a shape mistake there would otherwise surface as a renderer bug in a third one.

Summary

Functions

Invokes a host graph projector, then validates the shape it returned.

Checks a presentation against the contract.

Callbacks

project(keyword)

@callback project(keyword()) ::
  {:ok, DocShell.Presentation.Source.presentation()} | {:error, term()}

Functions

project(module, opts)

@spec project(
  module(),
  keyword()
) :: {:ok, DocShell.Presentation.Source.presentation()} | {:error, term()}

Invokes a host graph projector, then validates the shape it returned.

validate(presentation)

@spec validate(term()) ::
  {:ok, DocShell.Presentation.Source.presentation()} | {:error, term()}

Checks a presentation against the contract.

Returns {:error, {:invalid_presentation, reason}} rather than a boolean so a host sees which part of the shape it got wrong.