diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-02-25 17:37:37 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-02-25 17:38:16 -0600 |
commit | 4eaeca88909af04d00eda22c20272f40a9e3548b (patch) | |
tree | 8115f24bfe9950aa40f8d966037e557c23549337 | |
parent | dcd8962afbe03a77c21d4f4f392a4bde0abfa1e3 (diff) |
add edoc provider
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/rebar.app.src | 1 | ||||
-rw-r--r-- | src/rebar_prv_edoc.erl | 48 |
3 files changed, 50 insertions, 0 deletions
@@ -33,6 +33,7 @@ limit scope. | ct | Run Common Test suites | | do | Higher-order provider to run multiple tasks in sequence | | dialyzer | Run the Dialyzer analyzer on the project | +| edoc | Generate documentation using edoc | | eunit | Run eunit tests | | help | Print help for rebar or task | | new | Create new rebar project from templates | diff --git a/src/rebar.app.src b/src/rebar.app.src index 1314ead..e5f21ea 100644 --- a/src/rebar.app.src +++ b/src/rebar.app.src @@ -29,6 +29,7 @@ rebar_prv_dialyzer, rebar_prv_do, rebar_prv_eunit, + rebar_prv_edoc, rebar_prv_lock, rebar_prv_install_deps, rebar_prv_packages, diff --git a/src/rebar_prv_edoc.erl b/src/rebar_prv_edoc.erl new file mode 100644 index 0000000..8397e20 --- /dev/null +++ b/src/rebar_prv_edoc.erl @@ -0,0 +1,48 @@ +-module(rebar_prv_edoc). + +-behaviour(provider). + +-export([init/1, + do/1, + format_error/1]). + +-include("rebar.hrl"). + +-define(PROVIDER, edoc). +-define(DEPS, [app_discovery]). + +%% =================================================================== +%% Public API +%% =================================================================== + +-spec init(rebar_state:t()) -> {ok, rebar_state:t()}. +init(State) -> + State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, + {module, ?MODULE}, + {bare, false}, + {deps, ?DEPS}, + {example, "rebar edoc"}, + {short_desc, "Generate documentation using edoc."}, + {desc, ""}, + {opts, []}])), + {ok, State1}. + +-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. +do(State) -> + ProjectApps = rebar_state:project_apps(State), + EDocOpts = rebar_state:get(State, edoc_opts, []), + lists:foreach(fun(AppInfo) -> + AppName = ec_cnv:to_list(rebar_app_info:name(AppInfo)), + ?INFO("Running edoc for ~s", [AppName]), + AppDir = rebar_app_info:dir(AppInfo), + ok = edoc:application(list_to_atom(AppName), AppDir, EDocOpts) + end, ProjectApps), + {ok, State}. + +-spec format_error(any()) -> iolist(). +format_error(Reason) -> + io_lib:format("~p", [Reason]). + +%% =================================================================== +%% Internal functions +%% =================================================================== |