# `Alternera.Plugin.Recipes`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_plugin_sdk/lib/alternera/plugin/recipes.ex#L1)

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.

# `entry`

```elixir
@type entry() :: %{
  slug: String.t(),
  title: String.t(),
  description: String.t(),
  category: String.t() | nil,
  labels: %{required(String.t()) =&gt; 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.

# `categories`

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

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

# `intro`

```elixir
@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`

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

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

# `problems`

```elixir
@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`

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

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

# `strip`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
