aboutsummaryrefslogtreecommitdiffstats
path: root/system/doc/top/src/otp_man_index.erl
diff options
context:
space:
mode:
authorLars Thorsen <[email protected]>2010-08-23 15:40:18 +0200
committerLars Thorsen <[email protected]>2010-08-24 11:04:38 +0200
commit39bdab0727c157d3647600080cd4e70512be677b (patch)
treef4f051d3e9c2bd43a26ef8bd69275e4631361084 /system/doc/top/src/otp_man_index.erl
parent4bff75c637d2b0ac9a591a30e4e12d3ec9a80891 (diff)
downloadotp-39bdab0727c157d3647600080cd4e70512be677b.tar.gz
otp-39bdab0727c157d3647600080cd4e70512be677b.tar.bz2
otp-39bdab0727c157d3647600080cd4e70512be677b.zip
Fixed that the system documentation can be built from both a source and release structure.
Diffstat (limited to 'system/doc/top/src/otp_man_index.erl')
-rw-r--r--system/doc/top/src/otp_man_index.erl75
1 files changed, 45 insertions, 30 deletions
diff --git a/system/doc/top/src/otp_man_index.erl b/system/doc/top/src/otp_man_index.erl
index 0fdc531b37..4ad975c53d 100644
--- a/system/doc/top/src/otp_man_index.erl
+++ b/system/doc/top/src/otp_man_index.erl
@@ -27,14 +27,20 @@
-module(otp_man_index).
--export([gen/1]).
+-export([gen/1, gen/2]).
-include_lib("kernel/include/file.hrl").
-gen([RootDir, OutFile]) when is_atom(RootDir), is_atom(OutFile)->
+gen([Source, RootDir, OutFile]) when is_atom(RootDir), is_atom(OutFile)->
+ gen(Source, RootDir, OutFile).
+
+gen(RootDir, OutFile) ->
+ gen(rel, RootDir, OutFile).
+
+gen(Source, RootDir, OutFile) ->
Bases = [{"../lib/", filename:join(RootDir, "lib")},
{"../", RootDir}],
- Apps = find_application_paths(Bases),
+ Apps = find_application_paths(Source, Bases),
RefPages = find_ref_files(Apps),
gen_html(RefPages, atom_to_list(OutFile)).
@@ -81,43 +87,52 @@ find_ref_files([{App, Vsn, AppPath, RelPath} |Apps], Acc) ->
find_ref_files(Apps, Refs2 ++ Acc)
end.
-find_application_paths([]) ->
+find_application_paths(_, []) ->
[];
-find_application_paths([{URL, Dir} | Paths]) ->
- Sub1 = "doc/html",
+find_application_paths(Source, [{URL, Dir} | Paths]) ->
AppDirs = get_app_dirs(Dir),
-
- AppPaths =
- lists:map(
- fun({App, AppPath}) ->
- VsnFile = filename:join(AppPath, "vsn.mk"),
- VsnStr =
- case file:read_file(VsnFile) of
- {ok, Bin} ->
- case re:run(Bin, ".*VSN\s*=\s*([0-9\.]+).*",[{capture,[1],list}]) of
- {match, [V]} ->
- V;
- nomatch ->
- exit(io_lib:format("No VSN variable found in ~s\n",
- [VsnFile]))
- end;
- {error, Reason} ->
- exit(io_lib:format("~p : ~s\n", [Reason, VsnFile]))
- end,
- AppURL = URL ++ App ++ "-" ++ VsnStr,
- {App, VsnStr, AppPath ++ "/" ++ Sub1, AppURL ++ "/" ++ Sub1}
- end, AppDirs),
- AppPaths ++ find_application_paths(Paths).
-
+ AppPaths = get_app_paths(Source, AppDirs, URL),
+ AppPaths ++ find_application_paths(Source, Paths).
+get_app_paths(src, AppDirs, URL) ->
+ Sub1 = "doc/html",
+ lists:map(
+ fun({App, AppPath}) ->
+ VsnFile = filename:join(AppPath, "vsn.mk"),
+ VsnStr =
+ case file:read_file(VsnFile) of
+ {ok, Bin} ->
+ case re:run(Bin, ".*VSN\s*=\s*([0-9\.]+).*",[{capture,[1],list}]) of
+ {match, [V]} ->
+ V;
+ nomatch ->
+ exit(io_lib:format("No VSN variable found in ~s\n",
+ [VsnFile]))
+ end;
+ {error, Reason} ->
+ exit(io_lib:format("~p : ~s\n", [Reason, VsnFile]))
+ end,
+ AppURL = URL ++ App ++ "-" ++ VsnStr,
+ {App, VsnStr, AppPath ++ "/" ++ Sub1, AppURL ++ "/" ++ Sub1}
+ end, AppDirs);
+get_app_paths(rel, AppDirs, URL) ->
+ Sub1 = "doc/html",
+ lists:map(
+ fun({App, AppPath}) ->
+ [AppName, VsnStr] = string:tokens(App, "-"),
+ AppURL = URL ++ App,
+ {AppName, VsnStr, AppPath ++ "/" ++ Sub1, AppURL ++ "/" ++ Sub1}
+ end, AppDirs).
+
+
get_app_dirs(Dir) ->
{ok, Files} = file:list_dir(Dir),
AFiles =
lists:map(fun(File) -> {File, filename:join([Dir, File])} end, Files),
lists:zf(fun is_app_with_doc/1, AFiles).
-is_app_with_doc({"." ++ ADir, _APath}) ->
+is_app_with_doc({"." ++ _ADir, _APath}) ->
false;
is_app_with_doc({ADir, APath}) ->
case file:read_file_info(filename:join([APath, "info"])) of