Skip to content

Commit

Permalink
Normalise location to source files
Browse files Browse the repository at this point in the history
  • Loading branch information
daleharvey committed Nov 26, 2011
1 parent 20d4194 commit fd2ff81
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/erldocs_core.erl
Expand Up @@ -97,9 +97,10 @@ ensure_docsrc(AppDir, Conf) ->
Bnames = [bname(File, ".xml") || File <- XMLFiles], Bnames = [bname(File, ".xml") || File <- XMLFiles],


% Generate any missing module XML % Generate any missing module XML
SrcFiles = [File || File <- filelib:wildcard(filename:join([AppDir, "*.erl"])) ++ SrcFiles = [filename:absname(File)
filelib:wildcard(filename:join([AppDir, "src", "*.erl"])), || File <- filelib:wildcard(filename:join([AppDir, "*.erl"])) ++
not lists:member(bname(File, ".erl"), Bnames)], filelib:wildcard(filename:join([AppDir, "src", "*.erl"])),
not lists:member(bname(File, ".erl"), Bnames)],


% Output XML files to destination folder % Output XML files to destination folder
% This prevents polluting the source files % This prevents polluting the source files
Expand All @@ -112,19 +113,19 @@ ensure_docsrc(AppDir, Conf) ->




gen_docsrc(AppDir, SrcFiles, Dest) -> gen_docsrc(AppDir, SrcFiles, Dest) ->
Includes = filelib:wildcard(AppDir ++ "/include"), Opts = [{includes, filelib:wildcard(AppDir ++ "/include")},
{sort_functions,false}],

lists:foldl(fun(File, Acc) -> lists:foldl(fun(File, Acc) ->
log("Generating XML - ~s~n", [bname(File, ".erl")]), log("Generating XML - ~s~n", [bname(File, ".erl")]),
case (catch docb_gen:module( case (catch docb_gen:module(File, Opts)) of
File, [{includes, Includes}, ok ->
{sort_functions,false}])) of [filename:join([Dest, bname(File, ".erl")]) ++ ".xml"|Acc];
ok -> Error ->
[filename:join([Dest, bname(File, ".erl")]) ++ ".xml"|Acc]; log("Error generating XML (~p): ~p~n", [File, Error]),
Error -> Acc
log("Error generating XML (~p): ~p~n", [File, Error]), end
Acc end, [], SrcFiles).
end
end, [], SrcFiles).


%% @doc run a function with the cwd set, ensuring the cwd is reset once %% @doc run a function with the cwd set, ensuring the cwd is reset once
%% finished (some dumb functions require to be ran from a particular dir) %% finished (some dumb functions require to be ran from a particular dir)
Expand Down

0 comments on commit fd2ff81

Please sign in to comment.