summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rebar.config2
-rw-r--r--rebar.lock4
-rw-r--r--src/rebar_prv_edoc.erl5
-rw-r--r--src/rebar_state.erl22
-rw-r--r--test/rebar_edoc_SUITE.erl10
-rw-r--r--test/rebar_edoc_SUITE_data/foo/apps/foo/rebar.config1
-rw-r--r--test/rebar_edoc_SUITE_data/foo/rebar.config1
7 files changed, 35 insertions, 10 deletions
diff --git a/rebar.config b/rebar.config
index 1de146c..c2f00fb 100644
--- a/rebar.config
+++ b/rebar.config
@@ -10,7 +10,7 @@
{bbmustache, "1.6.1"},
{relx, "3.32.1"},
{cf, "0.2.2"},
- {cth_readable, "1.4.4"},
+ {cth_readable, "1.4.5"},
{eunit_formatters, "0.5.0"}]}.
{post_hooks, [{"(linux|darwin|solaris|freebsd|netbsd|openbsd)",
diff --git a/rebar.lock b/rebar.lock
index 6cec244..3661209 100644
--- a/rebar.lock
+++ b/rebar.lock
@@ -2,7 +2,7 @@
[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.6.1">>},0},
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},0},
{<<"cf">>,{pkg,<<"cf">>,<<"0.2.2">>},0},
- {<<"cth_readable">>,{pkg,<<"cth_readable">>,<<"1.4.4">>},0},
+ {<<"cth_readable">>,{pkg,<<"cth_readable">>,<<"1.4.5">>},0},
{<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"1.3.1">>},0},
{<<"eunit_formatters">>,{pkg,<<"eunit_formatters">>,<<"0.5.0">>},0},
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0},
@@ -15,7 +15,7 @@
{<<"bbmustache">>, <<"9FB63FA60BD53AFBF47F02E6D8BD6B2BEAFC068E02E20975254DC7461FD4F397">>},
{<<"certifi">>, <<"867CE347F7C7D78563450A18A6A28A8090331E77FA02380B4A21962A65D36EE5">>},
{<<"cf">>, <<"7F2913FFF90ABCABD0F489896CFEB0B0674F6C8DF6C10B17A83175448029896C">>},
- {<<"cth_readable">>, <<"6CEFD2C293F5F04A80F7DB45D1BAFF70E720681AC98E6A11B5FEF1BF5B14B9FB">>},
+ {<<"cth_readable">>, <<"BE3765763F9BEA87320F03F33B578875F8B3A4E8BD970EAE198AFF8A3F1AB38F">>},
{<<"erlware_commons">>, <<"0CE192AD69BC6FD0880246D852D0ECE17631E234878011D1586E053641ED4C04">>},
{<<"eunit_formatters">>, <<"6A9133943D36A465D804C1C5B6E6839030434B8879C5600D7DDB5B3BAD4CCB59">>},
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>},
diff --git a/src/rebar_prv_edoc.erl b/src/rebar_prv_edoc.erl
index c78296a..5e563ab 100644
--- a/src/rebar_prv_edoc.erl
+++ b/src/rebar_prv_edoc.erl
@@ -45,7 +45,10 @@ do(State) ->
AppName = rebar_utils:to_list(rebar_app_info:name(AppInfo)),
?INFO("Running edoc for ~ts", [AppName]),
AppDir = rebar_app_info:dir(AppInfo),
- AppRes = (catch edoc:application(list_to_atom(AppName), AppDir, EdocOptsAcc)),
+ AppOpts = rebar_app_info:opts(AppInfo),
+ %% order of the merge is important to allow app opts overrides
+ AppEdocOpts = rebar_opts:get(AppOpts, edoc_opts, []) ++ EdocOptsAcc,
+ AppRes = (catch edoc:application(list_to_atom(AppName), AppDir, AppEdocOpts)),
rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, AppInfo, State),
case {AppRes, ShouldAccPaths} of
{ok, true} ->
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 31d3a08..e7d772f 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -71,7 +71,7 @@
all_plugin_deps = [] :: [rebar_app_info:t()],
all_deps = [] :: [rebar_app_info:t()],
- compilers = [] :: [{compiler_type(), extension(), extension(), compile_fun()}],
+ compilers = [] :: [module()],
project_builders = [] :: [{rebar_app_info:project_type(), module()}],
resources = [],
providers = [],
@@ -81,10 +81,6 @@
-type t() :: #state_t{}.
--type compiler_type() :: atom().
--type extension() :: string().
--type compile_fun() :: fun(([file:filename()], rebar_app_info:t(), list()) -> ok).
-
-spec new() -> t().
new() ->
BaseState = base_state(dict:new()),
@@ -407,15 +403,31 @@ warn_old_resource(ResourceModule) ->
?WARN("Using custom resource ~s that implements a deprecated api. "
"It should be upgraded to rebar_resource_v2.", [ResourceModule]).
+%% @doc get a list of all registered compiler modules, which should implement
+%% the `rebar_compiler' behaviour
+-spec compilers(t()) -> [module()].
compilers(#state_t{compilers=Compilers}) ->
Compilers.
+%% @doc register compiler modules prior to the existing ones. Each compiler
+%% module should implement the `rebar_compiler' behaviour. Use this when
+%% your custom compiler generates .erl files (or files of another type) and
+%% that should run before other compiler modules.
+-spec prepend_compilers(t(), [module()]) -> t().
prepend_compilers(State=#state_t{compilers=Compilers}, NewCompilers) ->
State#state_t{compilers=NewCompilers++Compilers}.
+%% @doc register compiler modules. Each compiler
+%% module should implement the `rebar_compiler' behaviour. Use this when
+%% your custom compiler generates binary artifacts and does not have
+%% a particular need to run before any other compiler.
+-spec append_compilers(t(), [module()]) -> t().
append_compilers(State=#state_t{compilers=Compilers}, NewCompilers) ->
State#state_t{compilers=Compilers++NewCompilers}.
+%% @private reset all compiler modules by replacing them by a list of
+%% modules that implement the `rebar_compiler' behaviour.
+-spec compilers(t(), [module()]) -> t().
compilers(State, Compilers) ->
State#state_t{compilers=Compilers}.
diff --git a/test/rebar_edoc_SUITE.erl b/test/rebar_edoc_SUITE.erl
index 64ec0c8..2f0fad0 100644
--- a/test/rebar_edoc_SUITE.erl
+++ b/test/rebar_edoc_SUITE.erl
@@ -52,7 +52,15 @@ multiapp(Config) ->
"barer1")),
?assert(file_content_matches(
filename:join([AppsDir, "apps", "foo", "doc", "foo.html"]),
- "apps/bar1/doc/bar1.html")).
+ "apps/bar1/doc/bar1.html")),
+ %% Options such from rebar.config in the app themselves are
+ %% respected
+ ?assert(file_content_matches(
+ filename:join([AppsDir, "apps", "foo", "doc", "overview-summary.html"]),
+ "foo_custom_title"
+ )),
+ ok.
+
error_survival(Config) ->
RebarConfig = [],
diff --git a/test/rebar_edoc_SUITE_data/foo/apps/foo/rebar.config b/test/rebar_edoc_SUITE_data/foo/apps/foo/rebar.config
new file mode 100644
index 0000000..970d4e2
--- /dev/null
+++ b/test/rebar_edoc_SUITE_data/foo/apps/foo/rebar.config
@@ -0,0 +1 @@
+{edoc_opts, [{title, "foo_custom_title"}]}.
diff --git a/test/rebar_edoc_SUITE_data/foo/rebar.config b/test/rebar_edoc_SUITE_data/foo/rebar.config
new file mode 100644
index 0000000..b5d44fa
--- /dev/null
+++ b/test/rebar_edoc_SUITE_data/foo/rebar.config
@@ -0,0 +1 @@
+{edoc_opts, [{title, "forced wrong title to be overridden"}]}.