Alternera.Plugin.Recipes (alternera_plugin_sdk v0.9.0)

Copy Markdown View Source

Reads a recipes file: the Markdown a plugin declares with use Alternera.Plugin, recipes: "…", and the proxy's own recipe files, in one format.

A recipe is a ##### section: its heading is the title, the paragraph under it the description, then its YAML blocks, a pipeline and its tests (a recipe with a private helper has three: the helper, the caller, the tests). The description paragraph may hold category: <word> and labels: key=value, key=value lines, which a search scores and which strip/1 leaves out of the text a model reads. The sections after an <!-- index --> line are index?: the proxy's aggregate recipes topic lists them by one line instead of in full. The slug comes from the title: lowercase, every run of other characters an underscore.

problems/1 is what the SDK's test kit (Plugin.Test.Contract) checks a declared file with, so a plugin's own suite fails on a recipe the proxy could not index.

Summary

Types

One recipe of a file, with topic, the guide topic of the file it came from.

Functions

The categories a recipe may name, the proxy's own and a tenant's alike.

The prose before a file's first recipe: the topic's introduction, as the proxy's aggregate recipes topic opens with it.

The recipes of a file's text, served under the guide topic topic.

What is wrong with a recipes file, as one line each; [] for a file the proxy indexes whole: at least one recipe, each with a title no other has, a description, a category of categories/0, well-formed labels and two or three YAML blocks.

A slug from a title: lowercase, every run of other characters an underscore.

A file's text with each recipe's category: and labels: lines left out.

Types

entry()

@type entry() :: %{
  slug: String.t(),
  title: String.t(),
  description: String.t(),
  category: String.t() | nil,
  labels: %{required(String.t()) => String.t()},
  topic: String.t(),
  index?: boolean(),
  text: String.t()
}

One recipe of a file, with topic, the guide topic of the file it came from.

Functions

categories()

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

The categories a recipe may name, the proxy's own and a tenant's alike.

intro(text)

@spec intro(String.t()) :: String.t()

The prose before a file's first recipe: the topic's introduction, as the proxy's aggregate recipes topic opens with it.

parse(text, topic)

@spec parse(String.t(), String.t()) :: [entry()]

The recipes of a file's text, served under the guide topic topic.

problems(text)

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

What is wrong with a recipes file, as one line each; [] for a file the proxy indexes whole: at least one recipe, each with a title no other has, a description, a category of categories/0, well-formed labels and two or three YAML blocks.

slug(title)

@spec slug(String.t()) :: String.t()

A slug from a title: lowercase, every run of other characters an underscore.

strip(text)

@spec strip(String.t()) :: String.t()

A file's text with each recipe's category: and labels: lines left out.