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.
Summary
Functions
Loads a single demo by name, returning {:ok, demo} or :error.
Lists every saved demo discoverable from the current working directory, sorted by name.
Loads a demo's emitted JS by evaluating its .exs file with stdout
captured. Returns the JS as a string.
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.
Types
Functions
Loads a single demo by name, returning {:ok, demo} or :error.
@spec list() :: [t()]
Lists every saved demo discoverable from the current working directory, sorted by name.
Loads a demo's emitted JS by evaluating its .exs file with stdout
captured. Returns the JS as a string.
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.