DocShell.Presentation.Renderer behaviour (DocShell v0.5.0)

Copy Markdown View Source

Defines the boundary between a portable site and a concrete renderer.

A renderer turns validated Page and Site values into output and declares the capabilities that output can honestly provide. admit/3 compares those capabilities with requirements derived from page content before rendering. Unsupported essential content fails; optional content is admitted only when its declared fallback still matches the projected page.

Renderers receive inert values and local logical assets. Authorization, application sessions, routing policy, deployment, and source collection stay with the host or projector. This behaviour therefore works for a hosted UI and a no-server static build without making either one the core abstraction.

Summary

Callbacks

Returns local assets needed by this site generation.

Returns the renderer's normalized capability declaration.

Renders the site's not-found page.

Renders one admitted page.

Functions

Checks that a renderer can satisfy one page in an output mode.

Returns the closed DSH.01 feature identifiers reserved by DocShell.

Callbacks

assets(t, keyword)

@callback assets(DocShell.Presentation.Site.t(), keyword()) ::
  {:ok, [DocShell.Presentation.Asset.t()]} | {:error, term()}

Returns local assets needed by this site generation.

capabilities()

@callback capabilities() :: DocShell.Presentation.Renderer.Capabilities.t()

Returns the renderer's normalized capability declaration.

render_not_found(t, t)

@callback render_not_found(
  DocShell.Presentation.Site.t(),
  DocShell.Presentation.Renderer.Context.t()
) ::
  {:ok, iodata()} | {:error, term()}

Renders the site's not-found page.

render_page(t, t)

@callback render_page(
  DocShell.Presentation.Page.t(),
  DocShell.Presentation.Renderer.Context.t()
) ::
  {:ok, iodata()} | {:error, term()}

Renders one admitted page.

Functions

admit(page, capabilities, mode)

@spec admit(
  DocShell.Presentation.Page.t(),
  DocShell.Presentation.Renderer.Capabilities.t(),
  :hosted | :static
) :: :ok | {:error, term()}

Checks that a renderer can satisfy one page in an output mode.

reserved_features()

@spec reserved_features() :: [String.t()]

Returns the closed DSH.01 feature identifiers reserved by DocShell.