summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--src/rebar.app.src1
-rw-r--r--src/rebar_prv_edoc.erl48
3 files changed, 50 insertions, 0 deletions
diff --git a/README.md b/README.md
index dce1937..bd0763c 100644
--- a/README.md
+++ b/README.md
@@ -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
+%% ===================================================================