Look up Elixir documentation from the command line
eh
basically works like IEx.Helpers.h
, except that you can run it
from the command line.
It prints the documentation for its first argument, if it can find any documentation on it.
Eh comes with a mix task for looking up code, mix eh
. It can find
documentation on any code it is compiled with, so if you install it
standalone, it will only be able to lookup built-in Elixir documentation
and its own documentation.
What's more interesting is to use it to lookup documentation on your
own packages, or on dependencies in your application. By adding eh
as
a development dependency to your package, you can do that from outside
of iex
, e.g. from your editor.
Add eh
as a development dependency to your project:
# mix.exs
def dependencies do
[{:eh, only: :dev}]
end
Install dependencies
mix deps.get
mix deps.compile
You should now be able to use mix eh
to lookup code in your project!
If you are a vim user, you can also set :keywordprog=mix\ eh
, and have
K
look up code in your project.
You can also install eh for your
You can install eh
with git, like so
git clone git@github.com:Frost/eh.git
cd eh
mix deps.get
mix escript.build
./eh Eh
Then you can put the eh
binary somewhere in your $PATH
and use it
from anywhere, like set :keywordprog=/path/to/eh
in your vimrc and
for Elixir files, and be able to lookup Elixir documentation with K
.
Examples:
mix eh String
- Module docs forString
mix eh is_binary
- Docs forKernel.is_binary
mix eh String.to_integer
- Docs for any arity ofString.to_integer
mix eh String.to_integer/1
- Docs forString.to_integer/1
mix eh String.to_integer/2
- Docs forString.to_integer/2
The output from eh
is monochrome because some colors don't really work
very well in some terminals. For instance, having bright yellow as a
documentation header on a white background (or the reverse of that)
makes the text completely illegible. That specific example was fixed in
my pull request, but
there might be other color combinations out there that also get messed
up, so therefore I chose to output the documentation in monochrome.
The project is inspired by ri (ruby interactive), that basically does the same thing, but for ruby.
I also took a lot of inspiration from IEx.Helpers.h
, since I basically
wanted that, but without having to fire up IEx first.
Some of the code for extracting documentation from modules is more or
less borrowed straight out of IEx.Introspection.h
, and thate code is
copyright 2012-2013 Plataformatec.
Pull requests are welcome.
eh String.to_integer(some, args)
->String.to_integer/2