diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-02-25 21:43:47 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-02-25 21:43:47 -0500 |
commit | 456b9ae8eaeae5a1fd3d103f182807c2bdba7442 (patch) | |
tree | 18fc2b92878d7068ab93b3fae0f1fc414f4b6017 | |
parent | 2f9c65c69003159091209189014f276c54998ce1 (diff) | |
parent | 4eaeca88909af04d00eda22c20272f40a9e3548b (diff) |
Merge pull request #189 from tsloughter/edoc
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 +%% =================================================================== |