https://github.com/vic/iexample
Mix formatted documentation iex examples.
https://github.com/vic/iexample
documentation elixir iex mix-format
Last synced: 12 months ago
JSON representation
Mix formatted documentation iex examples.
- Host: GitHub
- URL: https://github.com/vic/iexample
- Owner: vic
- License: apache-2.0
- Created: 2018-04-03T17:45:07.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T18:13:32.000Z (about 8 years ago)
- Last Synced: 2025-06-14T13:53:38.569Z (about 1 year ago)
- Topics: documentation, elixir, iex, mix-format
- Language: Elixir
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# IExample - Elixir formatted documentation examples.
[](https://travis-ci.org/vic/iexample)
[](https://hexdocs.pm/iexample)
## Usage
Just interpolate the result of `iexample` into your documentation strings.
Note that for this to work, your docs should allow interpolation (dont use `~S`)
*and* the interpolation should happen at the start of a new line.
The `iexample/2` macro takes the expression result and a code block, and simply generates
an iex example string.
The following code from `test/support/example.ex`, would generate:
```
iex> 12 * 3
36
```
```elixir
defmodule MyModule do
import IExample
@moduledoc """
Math works
#{
iexample(36) do
12 * 3
end
}
"""
end
```
Then just run `mix format` and the interpolated code should be formatted for you nicely.
## Installation
```elixir
def deps do
[
{:iexample, "~> 0.1"}
]
end
```
Documentation can be found at [https://hexdocs.pm/iexample](https://hexdocs.pm/iexample).