summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2016-08-25 08:56:44 -0400
committerFred Hebert <mononcqc@ferd.ca>2016-08-25 08:56:44 -0400
commit5d475eefa27ddbb7876d74a9a3f6f45267333d57 (patch)
tree2947e60c1619ab89d3a76018ffaf0a74ddae97e9
parent7c9fc43e6c317bc724d983897afff0f5d47e1543 (diff)
Make Edoc carry paths of pre-built libraries
Given the topological sort applied to top-level apps, we should be able to carry the edoc values for paths configured when more than one app exists. This allows multiple disjoint app to have defined cross-linking in the documentation. Tests pending.
-rw-r--r--src/rebar_prv_edoc.erl35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/rebar_prv_edoc.erl b/src/rebar_prv_edoc.erl
index 6cefe14..465fc34 100644
--- a/src/rebar_prv_edoc.erl
+++ b/src/rebar_prv_edoc.erl
@@ -33,17 +33,25 @@ do(State) ->
code:add_pathsa(rebar_state:code_paths(State, all_deps)),
ProjectApps = rebar_state:project_apps(State),
Providers = rebar_state:providers(State),
- EDocOpts = rebar_state:get(State, edoc_opts, []),
+ EdocOpts = rebar_state:get(State, edoc_opts, []),
+ ShouldAccPaths = not has_configured_paths(EdocOpts),
Cwd = rebar_state:dir(State),
rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, State),
- lists:foreach(fun(AppInfo) ->
- rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, AppInfo, State),
- 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),
- rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, AppInfo, State)
- end, ProjectApps),
+ lists:foldl(fun(AppInfo, EdocOptsAcc) ->
+ rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, AppInfo, State),
+ 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, EdocOptsAcc),
+ rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, AppInfo, State),
+ case ShouldAccPaths of
+ true ->
+ %% edoc wants / on all OSes
+ add_to_paths(EdocOptsAcc, AppDir++"/doc");
+ false ->
+ EdocOptsAcc
+ end
+ end, EdocOpts, ProjectApps),
rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, State),
rebar_utils:cleanup_code_path(rebar_state:code_paths(State, default)),
{ok, State}.
@@ -55,3 +63,12 @@ format_error(Reason) ->
%% ===================================================================
%% Internal functions
%% ===================================================================
+has_configured_paths(EdocOpts) ->
+ proplists:get_value(dir, EdocOpts) =/= undefined.
+
+add_to_paths([], Path) ->
+ [{doc_path, [Path]}];
+add_to_paths([{doc_path, Paths}|T], Path) ->
+ [{doc_path, [Path | Paths]} | T];
+add_to_paths([H|T], Path) ->
+ [H | add_to_paths(Path, T)].