You can evaluate arbitrary Elixir commands from the shell, like so:
$ elixir -e "IO.puts 1+1"
Thus, to access documentation you can invoke the h/1
macro from the module IEx.Helpers
:
$ elixir -e "require IEx.Helpers; IEx.Helpers.h(Enum.count)"
Obviously, writing the above line every time you want to look up the Elixir documentation for a module or function is very tedious, so instead you could create an executable shell script – say exdoc
– then add it to your PATH
.
Example Script
Note: Don’t forget to chmod u+x
on it.
#!/bin/bash
if [[ -z "$1" ]]; then
echo "USAGE: $(basename $0) [name]"
exit 1
fi
elixir -e "require IEx.Helpers; IEx.Helpers.h($1)"
Elixir Docs Command
$ exdoc Enum.count
$ exdoc Kernel
... etc
Cheers!