*** edoc_lib.erl Fri Sep 16 11:52:06 2005 --- /usr/local/lib/erlang/lib/edoc-0.6.1/src/edoc_lib.erl Thu Dec 16 16:06:59 2004 *************** *** 30,37 **** -export([count/2, lines/1, split_at/2, split_at_stop/1, filename/1, transpose/1, segment/2, get_first_sentence/1, is_space/1, strip_space/1, escape_uri/1, join_uri/2, is_relative_uri/1, ! is_name/1, find_doc_dirs/0, find_doc_dirs/1, ! find_sources/2, find_sources/3, find_file/3, try_subdir/2, unique/1, write_file/3, write_file/4, write_info_file/4, read_info_file/1, get_doc_env/1, get_doc_env/4, copy_file/2, copy_dir/2, --- 30,36 ---- -export([count/2, lines/1, split_at/2, split_at_stop/1, filename/1, transpose/1, segment/2, get_first_sentence/1, is_space/1, strip_space/1, escape_uri/1, join_uri/2, is_relative_uri/1, ! is_name/1, find_doc_dirs/0, find_sources/2, find_sources/3, find_file/3, try_subdir/2, unique/1, write_file/3, write_file/4, write_info_file/4, read_info_file/1, get_doc_env/1, get_doc_env/4, copy_file/2, copy_dir/2, *************** *** 675,686 **** "". find_doc_dirs() -> ! find_doc_dirs(false). ! find_doc_dirs(AnyHtml) -> ! find_doc_dirs1(code:get_path(), AnyHtml). ! ! find_doc_dirs1([P0 | Ps], AnyHtml) -> P = filename:absname(P0), P1 = case filename:basename(P) of ?EBIN_DIR -> --- 674,682 ---- "". find_doc_dirs() -> ! find_doc_dirs(code:get_path()). ! find_doc_dirs([P0 | Ps]) -> P = filename:absname(P0), P1 = case filename:basename(P) of ?EBIN_DIR -> *************** *** 688,766 **** _ -> P end, - AppName = guess_app_name(P1), Dir = try_subdir(P1, ?EDOC_DIR), File = filename:join(Dir, ?INFO_FILE), ! case {filelib:is_file(File), AnyHtml} of ! {true,_} -> ! [Dir | find_doc_dirs1(Ps, AnyHtml)]; ! {false, true} -> ! Mods = get_mods(P0), ! case exists_html(Dir, Mods) of ! {true, Ms} -> ! [{AppName, Dir, Ms} | find_doc_dirs1(Ps, AnyHtml)]; ! false -> ! Dir1 = filename:join(Dir, "html"), ! case exists_html(Dir1, Mods) of ! {true, Ms} -> ! [{AppName, Dir1, Ms} | ! find_doc_dirs1(Ps, AnyHtml)]; ! false -> ! find_doc_dirs1(Ps, AnyHtml) ! end ! end end; ! find_doc_dirs1([], _) -> []. - guess_app_name(Dir) -> - {ok,[App|_]} = regexp:split(filename:basename(Dir), "-"), - list_to_atom(App). - - get_mods(P) -> - Ext = tl(code:objfile_extension()), - case file:list_dir(P) of - {ok, Fs} -> - lists:foldl( - fun(F, Acc) -> - case regexp:split(F, "\\.") of - {ok, [MStr, Ext]} -> - [MStr|Acc]; - _ -> - Acc - end - end, [], Fs); - _ -> - [] - end. - - - exists_html(Dir, Mods) -> - case file:list_dir(Dir) of - {ok, Fs} -> - case lists:foldl( - fun(F, Acc) -> - case regexp:split(F, "\\.") of - {ok, [M, "html"]} -> - case lists:member(M, Mods) of - true -> - [list_to_atom(M) | Acc]; - false -> - Acc - end; - _Other -> - Acc - end - end, [], Fs) of - [] -> - false; - [_|_] = Ms -> - {true, Ms} - end; - _ -> - false - end. - %% All names with "internal linkage" are mapped to the empty string, so %% that relative references will be created. For apps, the empty string %% implies that we use the default app-path. --- 684,700 ---- _ -> P end, Dir = try_subdir(P1, ?EDOC_DIR), File = filename:join(Dir, ?INFO_FILE), ! case filelib:is_file(File) of ! true -> ! [Dir | find_doc_dirs(Ps)]; ! false -> ! find_doc_dirs(Ps) end; ! find_doc_dirs([]) -> []. %% All names with "internal linkage" are mapped to the empty string, so %% that relative references will be created. For apps, the empty string %% implies that we use the default app-path. *************** *** 769,782 **** %% DEFER-OPTIONS: get_doc_env/4 get_doc_links(App, Packages, Modules, Opts) -> ! AnyHtml = proplists:get_value(ref_any_html, Opts, false), ! Path = proplists:append_values(doc_path, Opts) ++ find_doc_dirs(AnyHtml), ! Ds = lists:map( ! fun({AppName, P, Mods}) -> ! {P, {AppName, [], Mods}}; ! (P) when is_list(P) -> ! {P, uri_get_info_file(P)} ! end, Path), Ds1 = [{"", {App, Packages, Modules}} | Ds], D = dict:new(), make_links(Ds1, D, D, D). --- 703,710 ---- %% DEFER-OPTIONS: get_doc_env/4 get_doc_links(App, Packages, Modules, Opts) -> ! Path = proplists:append_values(doc_path, Opts) ++ find_doc_dirs(), ! Ds = [{P, uri_get_info_file(P)} || P <- Path], Ds1 = [{"", {App, Packages, Modules}} | Ds], D = dict:new(), make_links(Ds1, D, D, D).