# `DemoDirector.Demos`
[🔗](https://github.com/ralmidani/demo_director/blob/v0.1.1/lib/demo_director/demos.ex#L1)

Discovers and parses metadata from saved demo scripts.

Demos are `.exs` files in `priv/demos/` (host-app demos) or
`dev/priv/demos/` (this package's own demos). Each file's leading
comment block is parsed for two pieces of metadata:

  * the first `# Demo: …` comment becomes the demo's title
  * an optional `# @start_at "/path"` comment declares which route
    the demo expects the user to be on before it runs

Anything past the leading comment block is the script body that
emits JS via `IO.puts`.

# `t`

```elixir
@type t() :: %DemoDirector.Demos{
  name: String.t(),
  path: String.t(),
  start_at: String.t() | nil,
  title: String.t()
}
```

# `fetch`

```elixir
@spec fetch(String.t()) :: {:ok, t()} | :error
```

Loads a single demo by name, returning `{:ok, demo}` or `:error`.

# `list`

```elixir
@spec list() :: [t()]
```

Lists every saved demo discoverable from the current working
directory, sorted by name.

# `load_js`

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

Loads a demo's emitted JS by evaluating its `.exs` file with stdout
captured. Returns the JS as a string.

# `parse_metadata`

```elixir
@spec parse_metadata(String.t()) :: {String.t() | nil, String.t() | nil}
```

Extracts `{title, start_at}` from the leading comment block of a
demo script's contents. Returns `{nil, nil}` if neither is present.
Public for testability.

---

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