summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar.app.src1
-rw-r--r--src/rebar_prv_edoc.erl48
2 files changed, 49 insertions, 0 deletions
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
+%% ===================================================================