Skip to content

vic/iexample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IExample - Elixir formatted documentation examples.

Travis Hex.pm

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
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

def deps do
  [
    {:iexample, "~> 0.1"}
  ]
end

Documentation can be found at https://hexdocs.pm/iexample.

About

Mix formatted documentation iex examples.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages